VariableModeValueDto.fromJson constructor
VariableModeValueDto.fromJson(
- dynamic json
Implementation
factory VariableModeValueDto.fromJson(dynamic json) {
if (json is bool) {
return VariableModeBooleanDto(value: json);
} else if (json is num) {
return VariableModeDoubleDto(value: json.toDouble());
} else if (json is String) {
return VariableModeStringDto(value: json);
} else if (json is Map<String, dynamic>) {
if (json.containsKey('r') &&
json.containsKey('g') &&
json.containsKey('b') &&
json.containsKey('a')) {
return VariableModeColorDto.fromJson(json);
} else if (json.containsKey('type') && json['type'] == 'VARIABLE_ALIAS') {
return VariableModeAliasDto.fromJson(json);
}
}
throw Exception('Unsupported value type');
}