Map<String, ActionHandler>
;This map tells Beagle which action to trigger when a given identifier comes from a JSON.
The key in a map of actions is a string and it must be equivalent to the _beagleAction_
property of the JSON. These keys have a single restriction: they must have the prefix “custom:”.
An action handler is a function that receives the following named parameters:
The most important parameter is the action and most action handlers will need only this to be implemented. See an example below of an action that logs a message to the console:
final Map<String, ActionHandler> myActions = {
'custom:log': ({required action, required element, required view, required context}) {
log(action.getAttributeValue('message'));
},
};
final beagleService = BeagleService(
baseUrl: 'http://myBFF.com',
components: defaultComponents,
actions: {...myActions, ...defaultActions},
);
That’s it! Now you can use your custom action with Beagle Flutter!
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.