read<T> method
Reads the nearest instance of T provided by this node or an
ancestor, checking this node first.
Not reactive: whether it finds a match or not, the result is cached
until the node is unmounted, so a later provide call for T won't be
picked up until then.
Throws a StateError if this node is not mounted yet, or if no T was
ever provided.
Implementation
T read<T>() {
final value = readOrNull<T>();
if (value != null) return value;
throw StateError('No provider found for $T.');
}