decodeWithReviver method
decode method with a reviver
to instantiate the correct objects from model
Implementation
dynamic decodeWithReviver(String source) {
return decode(source, reviver: (key, value) {
if (value is List && value.isNotEmpty) {
if (value[0] is Map) {
return List<Map<String, dynamic>>.from(value);
} else if (value[0] is List) {
return List<List>.from(value);
}
}
return value;
});
}