of static method

ScrollNotificationObserverState of(
  1. BuildContext context

The closest instance of this class that encloses the given context.

If no ancestor 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 ScrollNotificationObserver in the context.

See also:


static ScrollNotificationObserverState of(BuildContext context) {
  final ScrollNotificationObserverState? observerState = maybeOf(context);
  assert(() {
    if (observerState == null) {
      throw FlutterError(
        'ScrollNotificationObserver.of() was called with a context that does not contain a '
        'ScrollNotificationObserver widget.\n'
        'No ScrollNotificationObserver widget ancestor could be found starting from the '
        'context that was passed to ScrollNotificationObserver.of(). This can happen '
        'because you are using a widget that looks for a ScrollNotificationObserver '
        'ancestor, but no such ancestor exists.\n'
        'The context used was:\n'
        '  $context',
    return true;
  return observerState!;