NodeFlowAction<T> class abstract

Base class for actions that can be triggered in the node flow editor.

An action represents a user operation that can be executed via keyboard shortcuts, menu items, or programmatically. Actions encapsulate both the operation logic and metadata for UI presentation.

Each action has:

  • Unique id for identification and mapping to shortcuts
  • Human-readable label for menus and command palettes
  • Optional description for tooltips
  • category for grouping in menus
  • execute method that performs the operation
  • canExecute method for conditional enabling

Example implementation:

class MyCustomAction<T> extends NodeFlowAction<T> {
  const MyCustomAction()
    : super(
        id: 'my_custom_action',
        label: 'My Custom Action',
        description: 'Does something custom',
        category: 'Custom',
      );

  @override
  bool execute(NodeFlowController<T, dynamic> controller, BuildContext? context) {
    // Perform the action
    controller.selectAllNodes();
    return true; // Return true if action succeeded
  }

  @override
  bool canExecute(NodeFlowController<T, dynamic> controller) {
    return controller.nodes.isNotEmpty;
  }
}

Constructors

NodeFlowAction({required String id, required String label, String? description, String category = 'General'})
const

Properties

category → String
Category for organizing actions in menus.
final
description → String?
Optional description providing additional context.
final
hashCode → int
The hash code for this object.
no setterinherited
id → String
Unique identifier for this action.
final
label → String
Human-readable label for UI presentation.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

canExecute(NodeFlowController<T, dynamic> controller) → bool
Checks if this action can be executed in the current state.
execute(NodeFlowController<T, dynamic> controller, BuildContext? context) → bool
Executes the action's operation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited