invokeAction method Null safety
- 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. This function will assert if the action is not
enabled when called.
Implementation
Object? invokeAction(
covariant Action<Intent> action,
covariant Intent intent, [
BuildContext? context,
]) {
assert(action != null);
assert(intent != null);
assert(action.isEnabled(intent), 'Action must be enabled when calling invokeAction');
if (action is ContextAction) {
context ??= primaryFocus?.context;
return action.invoke(intent, context);
} else {
return action.invoke(intent);
}
}