Flutter HTTP异常'(HttpException)=> Null'不是'(dynamic)=> dynamic'类型的子类型

时间:2020-05-04 18:26:45

标签: http flutter dart

我正在尝试通过http get请求获取一些数据。这是我的代码:

  Future searchProducts(String search) async {
    var response = await http.get(baseUrl + 'searchProducts');
    var jsonResponse = await convert.jsonDecode(response.body);
    print(jsonResponse['result'].length);
  }

我正在尝试在响应的正文中获取列表。当列表太大时,我收到此错误:

E/flutter (12726): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic'

如果我限制获取的数据:

I/flutter (12726): 20

0 个答案:

没有答案