getActionShortcut method
Gets the keyboard shortcut string for an action.
This returns a human-readable string representation of the keyboard shortcut assigned to an action, suitable for display in UI elements like menus or tooltips.
Parameters:
actionId: The unique identifier of the action
Returns a string like "Ctrl+C" or "Cmd+Shift+Z", or null if no shortcut is assigned or the action doesn't exist.
Example:
Widget build(BuildContext context) {
final deleteShortcut = getActionShortcut('delete_selection');
return ListTile(
title: const Text('Delete'),
trailing: Text(deleteShortcut ?? ''),
onTap: () => executeAction('delete_selection'),
);
}
Implementation
String? getActionShortcut(String actionId) {
final controller = nodeFlowController;
if (controller == null) return null;
final shortcut = controller.shortcuts.getShortcutForAction(actionId);
return shortcut != null ? _shortcutToString(shortcut) : null;
}