NotifierBuilder<N extends BaseNotifier<S>, S extends Object?> constructor

const NotifierBuilder<N extends BaseNotifier<S>, S extends Object?>({
  1. required BuilderCallback<S> builder,
  2. ShouldProceedCallback<S>? buildWhen,
  3. void onInit(
    1. N notifier
    )?,
  4. Widget? child,
  5. Key? key,
})

Creates a NotifierBuilder.

builder is called to build the widget tree based on the current state.

buildWhen is an optional predicate that determines whether to rebuild when the state changes.

onInit is 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'),
)

key is the widget key.

Implementation

const NotifierBuilder({
  required BuilderCallback<S> super.builder,
  super.buildWhen,
  super.onInit,
  super.child,
  super.key,
});