read<T> method

T read<T>()

The T of the nearest provider of one above this context, without depending on it: for callbacks, as context.read<Counter>().increment() on a key, and for State.initState. A ProviderNotFoundException if there is none, unless T is nullable: then null.

As with package:provider, a build had better WatchContext.watch: what it read is not rebuilt when it changes.

Implementation

T read<T>() => Provider.of<T>(this, listen: false);