createTriggerExecutor method

TriggerExecutor<TriggerConfiguration>? createTriggerExecutor(
  1. int triggerId,
  2. TriggerConfiguration trigger
)

Create a TriggerExecutor based on the trigger type. Returns null if trigger is not supported by any registered TriggerFactory factories.

Implementation

TriggerExecutor? createTriggerExecutor(
  int triggerId,
  TriggerConfiguration trigger,
) {
  if (_triggerExecutors[triggerId] == null) {
    TriggerExecutor? executor;

    if (_triggerFactories[trigger.runtimeType] != null) {
      executor = _triggerFactories[trigger.runtimeType]!.create(trigger);
    }

    if (executor != null) {
      _triggerExecutors[triggerId] = executor;
    } else {
      warning(
          "$runtimeType - Unknown trigger type. Cannot find a TriggerExecutor for the trigger of type '${trigger.runtimeType}'.");
      return null;
    }
  }
  return _triggerExecutors[triggerId]!;
}