startCommand method

  1. @mustCallSuper
bool startCommand(
  1. String name
)

Start the command with the given name.

Returns true if the command was handled.

Implementation

@mustCallSuper
bool startCommand(final String name) {
  final command = commands[name];
  if (command != null) {
    final interval = command.interval;
    NextRun<Command>? nextRun;
    for (var i = 0; i < stoppedCommands.length; i++) {
      nextRun = stoppedCommands[i];
      if (nextRun.value == command) {
        stoppedCommands.removeAt(i);
        commandNextRuns.add(nextRun);
        break;
      }
    }
    nextRun ??= getCommandNextRun(command);
    final runAfter = nextRun?.runAfter ?? command.interval;
    if (interval == null || (runAfter != null && runAfter >= interval)) {
      runCommand(command);
    }
    return true;
  }
  return false;
}