preExecute method
An initial run of validations before executing an Action. E.g.: a confirmation message like "Are you sure you want to delete this record?".
Implementation
@protected
Future<bool> preExecute(NodeSpec action, ActionContext context) async {
final props = action.props;
final evaluatorContext = getEvaluatorContext(
context.actionValue, context.state, context.actionContext);
properties.evaluateMap(props, evaluatorContext);
if (props["executeCondition"] != null &&
!properties.evaluateCondition(props["executeCondition"])) {
log.warningWithContext(
"Execute condition not met for Action '${action.type}' (${action.id}).",
props["executeCondition"]);
return false;
}
if (props["confirmation"] is Map) {
final confirmSpec = props["confirmation"] as Map;
return await widgets.showConfirmation(
title: confirmSpec["title"],
message: confirmSpec["message"],
props: confirmSpec,
);
}
log.infoWithContext(
"Executing Action '${action.type}' (${action.id})",
{}
..addAll({"action": props})
..addAll(evaluatorContext));
return true;
}