【发布时间】:2021-05-24 14:55:48
【问题描述】:
嘿!,
所以我发现 List() 已被弃用。如何启动列表并运行我的 _data.length 长度并现在用我的 json _data[I] 填充它?
问候 菜鸟TopTickTom
class WakeProvider {
Client client = Client();
fetchFeatures() async {
final response = await client.get('$_root/.json');
if (response.statusCode == 200) {
final parsedJson = json.decode(response.body);
List _data = parsedJson['employee'];
List _result = List();
for (int i = 0; i < _data.length; i++) {
_result.add(EmployeeModel.fromJson(_data[i]));
}
return _result;
} else {
throw NullThrownError();
}
}
【问题讨论】:
-
nvm 是这样修复的:``` List _result = []; ```
-
继续添加答案。永远不知道有一天它会帮助谁。
标签: flutter dart deprecated