canExecuteAction method

bool canExecuteAction(
  1. String actionId
)

Checks if a NodeFlow action can currently be executed.

This is useful for enabling/disabling UI elements based on whether their associated actions can be performed.

Parameters:

  • actionId: The unique identifier of the action to check

Returns true if the action exists and can be executed, false otherwise.

Example:

Widget build(BuildContext context) {
  return ElevatedButton(
    onPressed: canExecuteAction('undo') ? _undo : null,
    child: const Text('Undo'),
  );
}

Implementation

bool canExecuteAction(String actionId) {
  final controller = nodeFlowController;
  if (controller == null) return false;

  final action = controller.shortcuts.getAction(actionId);
  return action?.canExecute(controller) ?? false;
}