【问题标题】:Getting this error, "Exception has occurred. _TypeError (type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic')" ,收到此错误,“发生异常。_TypeError (type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic')”,
【发布时间】:2020-03-16 09:05:19
【问题描述】:

使用 flutter_auth0 ,当它指向 auth0 的 auth0 身份验证页面时遇到问题。

【问题讨论】:

    标签: flutter dart auth0


    【解决方案1】:

    您的直接问题是您在某处有一个错误处理函数,它只接受 HttpException 作为参数,但需要一个接受任何对象的函数,因为类型系统不知道您只需要捕获 @987654322 @s。 我无法从屏幕截图中看到该函数的来源,但请查找以 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");
    }
    

    )

    【讨论】:

      猜你喜欢
      • 2021-09-08
      • 2021-10-22
      • 1970-01-01
      • 2020-04-12
      • 1970-01-01
      • 2020-02-14
      • 1970-01-01
      • 2023-02-17
      • 2021-02-21
      相关资源
      最近更新 更多