builder property

BuilderCallback<S>? builder
finalinherited

Function to build the widget based on the current state and optional child.

This function is called whenever the widget needs to rebuild. It receives the current state and an optional child widget.

Example:

NotifierBuilder<CounterNotifier, int>(
  builder: (state, child) => Column(
    children: [
      Text('Count: $state'),
      if (child != null) child, // Render the child if provided
    ],
  ),
  child: ElevatedButton(
    onPressed: () => context.read<CounterNotifier>().increment(),
    child: Text('Increment'),
  ),
)

Implementation

final BuilderCallback<S>? builder;