create method

  1. @override
TriggerExecutor<TriggerConfiguration>? create(
  1. TriggerConfiguration trigger
)
override

Create a TriggerExecutor based on trigger. Returns null if trigger is not supported by this factory.

Implementation

@override
TriggerExecutor<TriggerConfiguration>? create(TriggerConfiguration trigger) {
  debug(
    '$runtimeType - Creating trigger executor for trigger type ${trigger.runtimeType}',
  );
  // TODO: implement specific handling of ScheduledTrigger
  if (trigger is ScheduledTrigger) {
    warning("ScheduledTrigger is not implemented yet.");
    return null;
  }

  try {
    if (_triggers.containsKey(trigger.runtimeType)) {
      return _triggers[trigger.runtimeType]!();
    }
  } catch (e) {
    warning(
      "$runtimeType - Failed to instantiate trigger executor for trigger type '${trigger.runtimeType}': $e",
    );
  }
  return null;
}