首页 > 解决方案 > 在 Dart 中发出 HTTP GET 请求时出现 TypeError

问题描述

使用 Darthttp包,我以这种方式创建请求:

var response = await http.get('some valid URL', headers: { ... })

有时,这会引发异常:

_TypeError (type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic')

整个请求块被 try...catch 子句包围,但由于某种原因,这个异常没有被捕获。问题是什么?

标签: httpflutterdart

解决方案


推荐阅读