dispatch static method

Future<Object?> dispatch(
  1. String command, [
  2. Map<String, dynamic> args = const {}
])

Runs the built-in command with args and returns its JSON-safe result.

Throws LiveException when the command is unknown, not allowed in this build mode, or fails.

Implementation

static Future<Object?> dispatch(
  String command, [
  Map<String, dynamic> args = const {},
]) async {
  final NyLiveHandler? handler = nyLiveBuiltIns[command];
  if (handler == null) {
    throw LiveException('Unknown live command "$command".');
  }
  if (!isDebugBuild && !readOnlyCommands.contains(command)) {
    throw LiveException('"$command" is only available in debug builds.');
  }
  return NyLiveJson.encodable(await handler(args));
}