of<T> static method
Method that allows widgets to access a provider
instance as long as their
BuildContext
contains a StreamsProvider instance.
If we want to access an instance of BlocA
which was provided higher up
in the widget tree we can do so via:
StreamsProvider.of<Provider>(context)
Implementation
static T of<T>(BuildContext context) {
try {
return Provider.of<T>(context, listen: false);
} on ProviderNotFoundException catch (_) {
throw FlutterError(
"""
StreamsProvider.of() called with a context that does not contain a provider of type $T.
No ancestor could be found starting from the context that was passed to StreamsProvider.of<$T>().
This can happen if the context you used comes from a widget above the StreamsProvider.
The context used was: $context
""",
);
}
}