NotifierRegister<N extends BaseNotifier<Object?> >.value constructor
const
NotifierRegister<N extends BaseNotifier<Object?> >.value ({
- required N notifier,
- Widget? child,
- Widget builder(
- BuildContext context,
- Widget? child
- Key? key,
Creates a NotifierRegister.value that provides an existing notifier instance.
notifier is the existing notifier instance to provide.
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 provide an existing notifier instance, typically for sharing a notifier across multiple parts of your app or when the notifier lifecycle is managed elsewhere.
Note: The notifier will NOT be automatically disposed when using this constructor. You are responsible for managing its lifecycle.
Example:
final counterNotifier = CounterNotifier();
NotifierRegister<CounterNotifier>.value(
notifier: counterNotifier,
child: MyApp(),
)
Implementation
const NotifierRegister.value({
required N this.notifier,
this.child,
this.builder,
super.key,
}) : create = null,
lazy = null;