Search code examples
iosflutterhttp-postreleaseunhandled

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 :

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


Solution

  • 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.