Home > Mobile >  Flutter/Dart iOS grey screen from unhandled http.post request on invalid url
Flutter/Dart iOS grey screen from unhandled http.post request on invalid url

Time:09-27

I have the classical grey screen issue on iOS release build, but I can't figure out a solution to remove the error :

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 :

net::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 :

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. Is there another way to do the same task without producing an error ?

Thanks

CodePudding user response:

Usually grey screen in flutter apps are because of render errors. 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.

CodePudding user response:

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.

  • Related