fromJson static method

VrControllerMessage fromJson(
  1. Map<String, dynamic> json
)

Implementation

static VrControllerMessage fromJson(Map<String, dynamic> json) {
  final kind = _jsonString(json, 'kind');
  return switch (kind) {
    'hello' => VrHelloMessage.fromJson(json),
    'ready' => VrReadyMessage.fromJson(json),
    'profile' => VrProfileMessage.fromJson(json),
    'pose' => VrPoseMessage.fromJson(json),
    'input' => VrInputMessage.fromJson(json),
    'ping' => VrPingMessage.fromJson(json),
    'pong' => VrPongMessage.fromJson(json),
    'disconnect' => VrDisconnectMessage.fromJson(json),
    'error' => VrErrorMessage.fromJson(json),
    _ => throw FormatException('Unknown controller message kind "$kind".'),
  };
}