VrControllerProfile.fromJson constructor
VrControllerProfile.fromJson(
- Map<String, dynamic> json
)
Implementation
factory VrControllerProfile.fromJson(Map<String, dynamic> json) {
final rawControls = json['controls'];
if (rawControls is! List) {
throw const FormatException(
'Invalid profile field "controls": expected a list.',
);
}
return VrControllerProfile(
protocolVersion: _jsonInt(json, 'protocolVersion'),
deviceId: _jsonString(json, 'deviceId'),
deviceName: _jsonString(json, 'deviceName'),
handedness: _jsonEnum(VrControllerHandedness.values, json, 'handedness'),
widthMeters: _jsonDouble(json, 'widthMeters'),
heightMeters: _jsonDouble(json, 'heightMeters'),
controls: rawControls
.map(
(value) =>
VrControlDescriptor.fromJson(_jsonMapValue(value, 'controls')),
)
.toList(growable: false),
);
}