fromWire static method

CommandMessage fromWire(
  1. Object? v
)

Implementation

static CommandMessage fromWire(Object? v) {
  final m = v as Map<String, dynamic>;
  if (m.length != 1) {
    throw FormatException('CommandMessage must be externally tagged: $v');
  }
  final tag = m.keys.single;
  final body = m[tag];
  switch (tag) {
    case 'CommandSubmit':
      return CommandMessageSubmit(CommandSubmit.fromWire(body));
    case 'CommandCancel':
      return CommandMessageCancel(CommandCancel.fromWire(body));
    case 'CommandEvents':
      return CommandMessageEvents(CommandEvents.fromWire(body));
    case 'CommandProjection':
      return CommandMessageProjection(CommandProjectionImage.fromWire(body));
    default:
      throw FormatException('unknown CommandMessage variant: $tag');
  }
}