of static method

GridViewObserverState of(
  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 no instance is found, this method will assert in debug mode, and throw an exception in release mode.

Calling this method will create a dependency on the closest ObserverWidget in the context.

See also:

  • ObserverWidget.maybeOf, which is similar to this method, but returns null if no ObserverWidget instance is found.

Implementation

static GridViewObserverState of(
  BuildContext context, {
  String? tag,
}) {
  final _state = ObserverWidget.of<
      GridObserverController,
      GridViewObserveModel,
      GridViewOnceObserveNotification,
      GridViewObserver>(
    context,
    tag: tag,
  );
  return _state as GridViewObserverState;
}