ReadContext extension
Finds what a provider above provides.
Builder(
builder: (context) =>
Button('Buy', onPressed: () => context.read<Cart>().add('tea')),
)
- on
Methods
-
read<
T> () → T -
Available on BuildContext, provided by the ReadContext extension
TheTof the nearest provider of one above this context, without depending on it: for callbacks, ascontext.read<Counter>().increment()on a key, and for State.initState. A ProviderNotFoundException if there is none, unlessTis nullable: then null.