getHandler<C extends Command> static method

CommandHandler<Command, dynamic> getHandler<C extends Command>(
  1. C command
)

The method to get a handler for a command. It will throw an error if no handler is registered for the command type.

Implementation

static CommandHandler getHandler<C extends Command>(C command) {
  final handler = _handlers[command.runtimeType];
  if (handler == null) {
    throw StateError(
      'No handler registered for command type: ${command.runtimeType}',
    );
  }
  return handler;
}