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 SliverViewObserver widget, then null is returned.
Calling this method will create a dependency on the closest
SliverViewObserver in the context, if there is one.
See also:
- SliverViewObserver.of, which is similar to this method, but asserts if no SliverViewObserver instance is found.
Implementation
static MixViewObserverState? maybeOf(
BuildContext context, {
String? tag,
}) {
final _state = ObserverWidget.maybeOf<SliverObserverController,
ObserveModel, ScrollViewOnceObserveNotification, SliverViewObserver>(
context,
tag: tag,
);
if (_state is! MixViewObserverState) return null;
return _state;
}