fromJson method
Converts JSON data to a list of Collectible instances.
Implementation
@override
List<Collectible> fromJson(List<dynamic>? json) {
if (json == null) {
return [];
} else {
return json.map(
(e) {
Collectible collectible = Collectible.fromJson(e);
final Map<String, dynamic>? metadata =
collectible.decodeDescriptorUri();
if (collectible.name == null && metadata?['name'] != null) {
collectible = collectible.copyWith(
name: metadata!['name'],
);
}
if (collectible.imageURL == null && metadata?['image'] != null) {
collectible = collectible.copyWith(
imageURL: metadata!['image'],
);
}
return collectible;
},
).toList();
}
}