收到此错误, "Exception has occurred. _TypeError (type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic')" ,

Getting this error, "Exception has occurred. _TypeError (type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic')" ,

使用 flutter_auth0 ,在重定向到 auth0.

的 auth0 身份验证页面时出现问题

你的直接问题是你在某个地方有一个错误处理函数,它只接受一个 HttpException 作为参数,但是需要一个接受任何对象的函数,因为类型系统不知道你只需要赶上 HttpExceptions。 我从屏幕截图中看不到该函数的来源,但寻找一个以 HttpException 作为参数的函数。

(其次,你正在急切地执行三个 HTTP 请求,一个 POST,一个 GET 和一个 PATCH 请求,那么你只等待其中一个。你可能需要延迟客户端请求,直到你有弄清楚你想要哪个。我会使用开关或函数映射:

var handlers = {
  "POST": () => _client.post(...),
  "GET": () => _client.get(...),
  "PATCH": () => _client.patch(...),
};
http.Response response = await handlers[method]();

http.Response response;
switch (method) {
  case "POST": 
   response = await _client.post(...);
   break;
  case "GET": 
   response = await _client.get(...);
   break;
  case "PATCH": 
   response = await _client.patch(...);
   break;
  default:
   throw UnsupportedError("Unknown method: $method");
}

)