of static method

ShortcutRegistry of(
  1. BuildContext context

Returns the ShortcutRegistry that belongs to the ShortcutRegistrar which most tightly encloses the given BuildContext.

If no ShortcutRegistrar widget encloses the context given, of will throw an exception in debug mode.

There is a default ShortcutRegistrar instance in WidgetsApp, so if WidgetsApp, MaterialApp or CupertinoApp are used, an additional ShortcutRegistrar isn't needed.

See also:


static ShortcutRegistry of(BuildContext context) {
  final _ShortcutRegistrarScope? inherited =
  assert(() {
    if (inherited == null) {
      throw FlutterError(
        'Unable to find a $ShortcutRegistrar widget in the context.\n'
        '$ShortcutRegistrar.of() was called with a context that does not contain a '
        '$ShortcutRegistrar widget.\n'
        'No $ShortcutRegistrar ancestor could be found starting from the context that was '
        'passed to $ShortcutRegistrar.of().\n'
        'The context used was:\n'
        '  $context',
    return true;
  return inherited!.registry;