onInit property

void Function(N notifier)? onInit
finalinherited

Function to execute when the widget is first created.

This is called once during initState and is useful for initializing the notifier or performing one-time setup operations.

Example:

NotifierBuilder<DataNotifier, List<String>>(
  onInit: (notifier) {
    notifier.loadData(); // Load data when widget is created
  },
  builder: (context, data, child) => ListView.builder(
    itemCount: data.length,
    itemBuilder: (context, index) => ListTile(title: Text(data[index])),
  ),
)

Implementation

final void Function(N notifier)? onInit;