0

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

aloys-c
  • 51
  • 5

2 Answers2

0

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.

  • Thanks for the answer, I have quite a lot of code and modules so it's quite a task to provide a minimum repoductible code. Now from what you say I believe the error doesn't come directly from the failed http request but the resulting difference in rendering, I will look in this direction thanks ! – aloys-c Sep 26 '22 at 09:14
  • Appreciate it. It is a daunting task to find out which section of the code is creating grey screen. I would recommend you comment out certain section of the code int that screen and build release version and install the app until you find out the part causing that issue. Alternatively, you could give sizedbox of certain height just to find out what is causing that issue. – Saurab Ghimire Sep 26 '22 at 09:41
0

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.

aloys-c
  • 51
  • 5