VectorValue.fromJson constructor
Builds a vector from a JSON map created by toJson.
Throws an ArgumentError if json does not have that shape. This is the JS SDK VectorValue.fromJSON().
Implementation
factory VectorValue.fromJson(Map<String, Object?> json) {
final Object? values = json['vectorValues'];
if (json['type'] != jsonType ||
values is! List<Object?> ||
values.any((Object? value) => value is! num)) {
throw ArgumentError.value(
json,
'json',
'Not a JSON representation of a VectorValue',
);
}
return VectorValue(<double>[
for (final Object? value in values) (value! as num).toDouble(),
]);
}