[SOLVED] Flutter web: How to hide alert message in the console when the HTTP status codes is failed?

Issue

This Content is from Stack Overflow. Question asked by Sittiphan Sittisak

I am using the API in Flutter.
Sometimes the server will return failed HTTP status codes and Flutter always auto-generated the alert message with shown the API URL in the console. I don’t want to shown the API URL and this alert message makes the app look not complete from the user’s perspective. I want to hide these alert messages. How to do that?

Example:
enter image description here



Solution

You can use the try/catch block.

try {
  await http.get('...')
  ...
} catch(e) {
  print(e);
}


This Question was asked in StackOverflow by Sittiphan Sittisak and Answered by Adil Shinwari It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?