简体   繁体   English

颤振/飞镖 iOS 来自未处理 http.post 请求的灰色屏幕无效 url

[英]Flutter/Dart iOS grey screen from unhandled http.post request on invalid url

I have the classical grey screen issue on iOS release build, but I can't figure out a solution to remove the error:我在 iOS 发布版本上遇到了经典的灰屏问题,但我无法找到消除错误的解决方案:

When the app is launched, the first operation is to do an async http request, however if the URL is invalid or the server unavailable, this will produce an error seen in web console as:当应用程序启动时,第一个操作是执行异步 http 请求,但是如果 URL 无效或服务器不可用,这将在 Z2567A5EC9705EB7AC2C984033E061 控制台中产生错误:

net::ERR_NAME_NOT_RESOLVED净::ERR_NAME_NOT_RESOLVED

In debug mode I have no errors displayed in the VSC console and you can see on my code that I am handling any possible the error:在调试模式下,VSC 控制台中没有显示任何错误,您可以在我的代码中看到我正在处理任何可能的错误:

dynamic fetchPost(url, Map<String, String>? args) async {
  try {
    var response = await http.post(
      Uri.parse(url),
      headers: {},
      body: args,
    );
    return response;
  } catch (e) {
    return false;
  }
}

Yet, if I build my app on iOS release this will produce a grey screen on start if the URL is invalid.然而,如果我在 iOS 版本上构建我的应用程序,如果 URL 无效,则会在启动时产生灰屏。 Is there another way to do the same task without producing an error?是否有另一种方法可以在不产生错误的情况下完成相同的任务?

Thanks谢谢

Usually grey screen in flutter apps are because of render errors. flutter 应用程序中的灰屏通常是由于渲染错误。 Look anywhere for widgets which do not have a fixed height or width in your home page or your entry screen.在主页或输入屏幕中寻找没有固定高度或宽度的小部件。 Please share the entry point of your app and minimum reproducible code for further debugging.请分享您的应用程序的入口点和最少的可重现代码,以便进一步调试。

Issue solved: the problem happened to be completely unrelated and about async loading of dependencies.问题已解决:问题恰好与依赖项的异步加载完全无关。 The working results I had were because I was using constants values in place of actually calling a function that wasn't ready yet.我得到的工作结果是因为我使用常量值来代替实际调用尚未准备好的 function。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM