fromJson method
Implementation
@override
Map<String, dynamic>? fromJson(dynamic json) {
if (json is List && json.isEmpty) {
// If it's an empty list, return an empty map
return <String, dynamic>{};
} else if (json is Map) {
// If it's a map, cast it and return
return Map<String, dynamic>.from(json);
}
// Handle null or other unexpected types
return null; // Or return <String, dynamic>{} based on preference
}