WatchContext extension
Finds what a provider above provides, and depends on it.
Builder(
builder: (context) => Text('${context.watch<Cart>().items.length} items'),
)
- on
Methods
-
watch<
T> () → T -
Available on BuildContext, provided by the WatchContext extension
TheTof the nearest provider of one above this context, which is rebuilt each time it changes, as long as its builds watch it. A ProviderNotFoundException if there is none, unlessTis nullable: then null.