ofNullable<T> static method
Retrieves the instance of type T from the widget tree, returns null if not found.
Implementation
static T? ofNullable<T>(
BuildContext context, {
bool listen = false,
}) {
try {
return Provider.of<T>(context, listen: listen);
} on ProviderNotFoundException catch (_) {
return null;
}
}