invokeAction method
- covariant Action<
Intent> action, - covariant Intent intent, [
- BuildContext? context
Invokes the given action
, passing it the given intent
.
The action will be invoked with the given context
, if given, but only if
the action is a ContextAction subclass. If no context
is given, and
the action is a ContextAction, then the context from the primaryFocus
is used.
Returns the object returned from Action.invoke.
The caller must receive a true
result from Action.isEnabled before
calling this function (or ContextAction.isEnabled with the same
context
, if the action
is a ContextAction). This function will
assert if the action is not enabled when called.
Consider using invokeActionIfEnabled to invoke the action conditionally based on whether it is enabled or not, without having to check first.
Implementation
Object? invokeAction(
covariant Action<Intent> action,
covariant Intent intent, [
BuildContext? context,
]) {
final BuildContext? target = context ?? primaryFocus?.context;
assert(action._isEnabled(intent, target), 'Action must be enabled when calling invokeAction');
return action._invoke(intent, target);
}