0

I am writing my first flutter app. I use there http.post request for logging user and also for changing data on server. When i turn off the internet connection it keeps waiting for the response and never falls into error. Is there any way to do that? I have been searching but haven't found anything.

Thanks!

Here is my code:

http.post(url).catchError((_) { active = previousState; notifyListeners(); }); 
2
  • You can also use the connectivity pack to check the network before you execute the post call. pub.dev/packages/connectivity Commented Mar 4, 2020 at 21:24
  • I tried the app on real phone and it worked. When i turned off the internet connection, it just went to catchError immediately. So the problem seems to appear only on phone emulator. So it is solved for now. Thank you guys for such a fast reply. @A.K. i am using my own server for api, so there might be problem even when the phone connection is ok. But that might be useful, thanks. Commented Mar 5, 2020 at 11:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.