NotifierRegister<N extends BaseNotifier<Object?> > constructor
const
NotifierRegister<N extends BaseNotifier<Object?> > ({
- required N create(
- BuildContext context
- bool? lazy,
- Widget? child,
- Widget builder(
- BuildContext context,
- Widget? child
- Key? key,
Creates a NotifierRegister that creates a new notifier instance.
create is a function that returns a new notifier instance when called.
lazy determines whether the notifier should be created lazily (default: true).
child is an optional static child widget.
builder is an optional builder function for customizing the widget tree.
key is the widget key.
Use this constructor when you want to create a new notifier instance that will be automatically disposed when the widget is removed from the tree.
Example:
NotifierRegister<CounterNotifier>(
create: (context) => CounterNotifier(),
lazy: false, // Create immediately
child: MyApp(),
)
Implementation
const NotifierRegister({
required this.create,
this.lazy,
this.child,
this.builder,
super.key,
}) : notifier = null;