maybeOf static method

MixViewObserverState? maybeOf(
  1. BuildContext context, {
  2. String? tag,
})

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:

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;
}