maybeOf static method

ListViewObserverState? 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 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:

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