maybeOf method Null safety

ShortcutManager? maybeOf(
  1. BuildContext context
)

Returns the ShortcutManager that most tightly encloses the given BuildContext.

If no Shortcuts widget encloses the context given, will return null.

See also:

  • of, which is similar to this function, but returns a non-nullable result, and will throw an exception if it doesn't find a Shortcuts ancestor.

Implementation

static ShortcutManager? maybeOf(BuildContext context) {
  assert(context != null);
  final _ShortcutsMarker? inherited = context.dependOnInheritedWidgetOfExactType<_ShortcutsMarker>();
  return inherited?.manager;
}