kfromJsonList<T> method
json 转 List
List<String>? list = str.kfromJsonList((json) => json as String?)
List<int>? list = str.kfromJsonList((json) => json as int?)
List<double>? list = str.kfromJsonList((json) => json as double?)
List<bool>? list = str.kfromJsonList((json) => json as bool?)
bean对象
List<User>? list = aListStr.kfromJsonList((json) => User.fromJson(json))
Implementation
List<T>? kfromJsonList<T>(T Function(dynamic json) fromJsonT) {
var file = this;
if (file == null || file.isEmpty) {
return null;
}
List list = json.decode(file);
return list.map((value) {
return fromJsonT(value);
}).toList();
}