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

Viewed 34

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

2 Answers

You can use the try/catch block.

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