onInit property

void Function(N notifier)? onInit
finalinherited

An optional callback invoked with the notifier when the widget is initialized. Note: Do not manually call the notifier's onInit() method here. The notifier itself will automatically trigger its own onInit() when it is created, so calling it again would result in duplicate invocations.

Example (incorrect usage):

NotifierBuilder<Notifier, State>(
  // Do NOT do this:
  onInit: (notifier) => notifier.onInit(),
  builder: (context, state) => Text('State: $state'),
)

Implementation

final void Function(N notifier)? onInit;