VrInputEventSnapshot.fromJson constructor
VrInputEventSnapshot.fromJson(
- Map<String, dynamic> json
)
Implementation
factory VrInputEventSnapshot.fromJson(Map<String, dynamic> json) {
final rawData = json['data'];
final decodedData = _fromWireValue(rawData);
if (decodedData != null && decodedData is! Map<String, dynamic>) {
throw const FormatException(
'Invalid input field "data": expected an object.',
);
}
final targetId = json['targetId'];
if (targetId != null && targetId is! String) {
throw const FormatException(
'Invalid input field "targetId": expected a string.',
);
}
final active = json['active'];
if (active is! bool) {
throw const FormatException(
'Invalid input field "active": expected a boolean.',
);
}
return VrInputEventSnapshot._(
type: _jsonEnum(VrInputType.values, json, 'type'),
source: _jsonEnum(VrInputSource.values, json, 'source'),
targetId: targetId as String?,
data: decodedData as Map<String, dynamic>?,
active: active,
timestampMicrosecondsSinceEpoch: _jsonInt(json, 'timestampUs'),
);
}