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?
Asked
Active
Viewed 354 times
0
-
This is what browsers usually do, it is not Flutter specific. You can try to use `try/catch` blocks around the code parts that can fail this way and try to suppress these messages. But I would not worry, users in general don't use browser's devtools. Check some famous sites, many of them has plenty on console. – Peter Koltai Sep 19 '22 at 05:40
2 Answers
0
You can use the try/catch block.
try {
await http.get('...')
...
} catch(e) {
print(e);
}

Tyler2P
- 2,324
- 26
- 22
- 31

Adil Shinwari
- 408
- 2
- 10
-
I used try catch, but this doesn't work. The message still shown in console. – Sittiphan Sittisak Sep 19 '22 at 16:27
0
'This is normal behavior for the browser' By https://github.com/flutter/flutter/issues/112155#issuecomment-1255310351
This is a way that can clear the console -> https://stackoverflow.com/a/73862039/17798537

Sittiphan Sittisak
- 486
- 4
- 15