read<N extends BaseNotifier<Object?> > method
N
read<N extends BaseNotifier<Object?> >()
Returns the nearest notifier of type N without listening to it.
Use this to call methods on a notifier, or to read its state once, from an event handler:
onPressed: () => context.read<CounterNotifier>().increment(),
This never rebuilds the widget when the state changes. To rebuild, use
NotifierBuilder or one of the other SyncX widgets.
Throws if no notifier of type N is registered above this context.
Implementation
N read<N extends BaseNotifier<Object?>>() =>
Provider.of<N>(this, listen: false);