callingAction property

  1. @protected
Action<T>? callingAction

The Action overridden by this Action.

The Action.overridable constructor creates an overridable Action that allows itself to be overridden by the closest ancestor Action, and falls back to its own defaultAction when no overrides can be found. When an override is present, an overridable Action forwards all incoming method calls to the override, and allows the override to access the defaultAction via its callingAction property.

Before forwarding the call to the override, the overridable Action is responsible for setting callingAction to its defaultAction, which is already taken care of by the overridable Action created using Action.overridable.

This property is only non-null when this Action is an override of the callingAction, and is currently being invoked from callingAction.

Invoking callingAction's methods, or accessing its properties, is allowed and does not introduce infinite loops or infinite recursions.

An example Action that handles PasteTextIntent but has mostly the same behavior as the overridable action. It's OK to call callingAction?.isActionEnabled in the implementation of this Action.
class MyPasteAction extends Action<PasteTextIntent> {
  Object? invoke(PasteTextIntent intent) {
    return callingAction?.invoke(intent);

  bool get isActionEnabled => callingAction?.isActionEnabled ?? false;

  bool consumesKey(PasteTextIntent intent) => callingAction?.consumesKey(intent) ?? false;


Action<T>? get callingAction => _currentCallingAction;