Skip to content

Commit a88d85d

Browse files
committed
Component Instances #32
1 parent dc9b0be commit a88d85d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/src/api/nodes/icon_node.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,23 @@ class IconNode extends SceneNode
108108
factory IconNode.fromJson(Map json) {
109109
// backwards compatibility: before properties were added to IconNode.
110110
if (json.containsKey('icon') && !json.containsKey('properties')) {
111+
// Very old model where icon was in IconNode.
111112
json['properties'] = <String, dynamic>{
112-
'icon': json['icon'],
113-
'show': true,
114-
'color': json['color'],
113+
'icon': {
114+
'icon': json['icon'],
115+
'show': true,
116+
'color': json['color'],
117+
},
115118
};
116119
json.remove('icon');
117120
}
118-
if (json.containsKey('properties') && json['properties']['icon']['icon'] == null) {
121+
if (json.containsKey('properties') &&
122+
json['properties']['icon']['codepoint'] != null) {
119123
// Backwards compatibility for migration to MultiSourceIconModel.
124+
// Old model where properties.icon was IconModel.
120125
json['properties']['icon'] = {
121126
'icon': {
122-
'icon': json['properties']['icon'],
127+
'icon': json['icon'] ?? json['properties']['icon'],
123128
'show': true,
124129
'color': json['color'],
125130
},

0 commit comments

Comments
 (0)