of<T> static method
Retrieves the instance of type T from the widget tree.
Implementation
static T of<T>(
BuildContext context, {
bool listen = false,
}) {
try {
return Provider.of<T>(context, listen: listen);
} on ProviderNotFoundException catch (e) {
if (e.valueType != T) rethrow;
throw FlutterError(
'''
ClassProvider.of() called with a context that does not contain a $T.
No ancestor could be found starting from the context that was passed to ClassProvider.of<$T>().
This can happen if the context you used comes from a widget above the ClassProvider.
The context used was: $context
''',
);
}
}