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

The T of 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, unless T is nullable: then null.