maybeOf<T> static method
Retrieves a dependency of type T from the nearest IoC provider in the widget tree, or null if not found.
Implementation
static T? maybeOf<T>(BuildContext context) {
InternalIocInheritedWidget<T>? dependencyWidget =
context
.getElementForInheritedWidgetOfExactType<
InternalIocInheritedWidget<T>
>()
?.widget
as InternalIocInheritedWidget<T>?;
if (dependencyWidget == null) return null;
return dependencyWidget.get(context);
}