Skip to content

Commit a0adc16

Browse files
committed
Fix icon props deserialization for backwards compatibility.
1 parent dba5743 commit a0adc16

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/src/api/nodes/icon_node.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,16 @@ class IconNode extends SceneNode
9393
];
9494

9595
/// Creates an [IconNode] from a JSON data.
96-
factory IconNode.fromJson(Map json) => _$IconNodeFromJson(json);
96+
factory IconNode.fromJson(Map json) {
97+
// backwards compatibility: before properties were added to IconNode.
98+
if (json.containsKey('icon') && !json.containsKey('properties')) {
99+
json['properties'] = <String, dynamic>{
100+
'icon': json['icon'],
101+
};
102+
json.remove('icon');
103+
}
104+
return _$IconNodeFromJson(json);
105+
}
97106

98107
@override
99108
Map toJson() => _$IconNodeToJson(this);

0 commit comments

Comments
 (0)