actions property
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. {@tool snippet} 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.
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();
},
);
}
{@end-tool} See also:
Implementation
final Map<Type, Action<Intent>>? actions;