@@ -129,30 +129,20 @@ abstract class ValueModel<T> with SerializableMixin {
129129
130130 /// Creates a new [ValueModel] instance from a JSON data.
131131 static ValueModel fromJson (Map json) {
132- if (json['type' ] != null ) {
133- final type = ValueType .values.byName (json['type' ]);
134- switch (type) {
135- case ValueType .bool :
136- return BoolValue .fromJson (json);
137- case ValueType .int :
138- return IntValue .fromJson (json);
139- case ValueType .double :
140- return DoubleValue .fromJson (json);
141- case ValueType .string:
142- return StringValue .fromJson (json);
143- case ValueType .color:
144- return ColorValue .fromJson (json);
145- case ValueType .paint:
146- return PaintValue .fromJson (json);
147- }
148- } else {
149- // backward compatibility
150- final value = json['value' ];
151- if (value is bool ? ) return BoolValue .fromJson (json);
152- if (value is int ) return IntValue .fromJson (json);
153- if (value is double ) return DoubleValue .fromJson (json);
154- if (value is String ) return StringValue .fromJson (json);
155- return IntValue .fromJson (json);
132+ final type = ValueType .values.byName (json['type' ]);
133+ switch (type) {
134+ case ValueType .bool :
135+ return BoolValue .fromJson (json);
136+ case ValueType .int :
137+ return IntValue .fromJson (json);
138+ case ValueType .double :
139+ return DoubleValue .fromJson (json);
140+ case ValueType .string:
141+ return StringValue .fromJson (json);
142+ case ValueType .color:
143+ return ColorValue .fromJson (json);
144+ case ValueType .paint:
145+ return PaintValue .fromJson (json);
156146 }
157147 }
158148}
0 commit comments