of method

ActionDispatcher of (
  1. BuildContext context,
  2. {bool nullOk: false}

Returns the ActionDispatcher associated with the Actions widget that most tightly encloses the given BuildContext.

Will throw if no ambient Actions widget is found.

If nullOk is set to true, then if no ambient Actions widget is found, this will return null.

The context argument must not be null.


static ActionDispatcher of(BuildContext context, {bool nullOk = false}) {
  assert(context != null);
  final _ActionsMarker marker = context.dependOnInheritedWidgetOfExactType<_ActionsMarker>();
  assert(() {
    if (nullOk) {
      return true;
    if (marker == null) {
      throw FlutterError('Unable to find an $Actions widget in the given context.\n'
          '$Actions.of() was called with a context that does not contain an '
          '$Actions widget.\n'
          'No $Actions ancestor could be found starting from the context that '
          'was passed to $Actions.of(). This can happen if the context comes '
          'from a widget above those widgets.\n'
          'The context used was:\n'
          '  $context');
    return true;
  return marker?.dispatcher ?? _findDispatcher(context);