actions property

Map<Type, Action<Intent>>? actions
final

The default map of intent keys to actions for the application.

By default, this is the output of WidgetsApp.defaultActions, called with defaultTargetPlatform. Specifying actions for an app overrides the default, so if you wish to modify the default actions, you can call WidgetsApp.defaultActions and modify the resulting map, passing it as the actions for this app. You may also add to the bindings, or override specific bindings for a widget subtree, by adding your own Actions widget.

This example shows how to add a single action handling an ActivateAction to the default actions without needing to add your own Actions widget.

Alternatively, you could insert a Actions widget with just the mapping you want to add between the WidgetsApp and its child and get the same effect.

link
Widget build(BuildContext context) {
  return WidgetsApp(
    actions: <Type, Action<Intent>>{
      ... WidgetsApp.defaultActions,
      ActivateAction: CallbackAction<Intent>(
        onInvoke: (Intent intent) {
          // Do something here...
          return null;
        },
      ),
    },
    color: const Color(0xFFFF0000),
    builder: (BuildContext context, Widget? child) {
      return const Placeholder();
    },
  );
}
See also:

  • The shortcuts parameter, which defines the default set of shortcuts for the application.
  • The Shortcuts widget, which defines a keyboard mapping.
  • The Actions widget, which defines the mapping from intent to action.
  • The Intent and Action classes, which allow definition of new actions.

Implementation

final Map<Type, Action<Intent>>? actions;