kfromJsonMapList<K, T> method
json转Map<K, List
Map<String, List<User>?>? mapList = str.kfromJsonMapList<String, User>((json) => User.fromJson(json));
Implementation
Map<K, List<T>?>? kfromJsonMapList<K, T>(T Function(dynamic json) fromJsonT) {
var file = this;
if (file == null || file.isEmpty) {
return null;
}
Map map = jsonDecode(file);
var newMap = <K, List<T>?>{};
map.forEach((key, value) {
if (value == null) {
newMap[key] = null;
} else {
List list = json.decode(value);
newMap[key] = list.map((value) {
return fromJsonT(value);
}).toList();
}
});
return newMap;
}