getFunction method

ActionFunction? getFunction(
  1. BuildContext context,
  2. dynamic actionSpec,
  3. Map state,
  4. Map? evaluatorContext,
)

Returns a ActionFunction that executes an Action based on it's actionSpec.

Implementation

ActionFunction? getFunction(BuildContext context, dynamic actionSpec,
    Map state, Map? evaluatorContext) {
  if (actionSpec == null) return null;
  if (EditorBloc.editMode) return () {};
  if (actionSpec is ActionFunction) return actionSpec;

  final nodeSpec =
      actionSpec is NodeSpec ? actionSpec : NodeSpec.fromMap(actionSpec);

  return () {
    run(context, nodeSpec, state, null, evaluatorContext);
  };
}