maybeOf static method
Returning the closest instance of this class that encloses the given context.
If you give a tag, it will give priority find the corresponding instance of this class with the given tag and return it.
If there is no ListViewObserver widget, then null is returned.
Calling this method will create a dependency on the closest
ListViewObserver in the context
, if there is one.
See also:
- ListViewObserver.of, which is similar to this method, but asserts if no ListViewObserver instance is found.
Implementation
static ListViewObserverState? maybeOf(
BuildContext context, {
String? tag,
}) {
final _state = ObserverWidget.maybeOf<
ListObserverController,
ListViewObserveModel,
ListViewOnceObserveNotification,
ListViewObserver>(
context,
tag: tag,
);
if (_state is! ListViewObserverState) return null;
return _state;
}