This is Flutter app with python(flask)
If I debug, it shows an exception
If I run the flutter app in chrome, it is interacting with flask and gives the correct response. But when I run this app in mobile, it shows the above error. I have included the internet permission in Android.manifest file.
2
Answers
You can’t reach localhost (127.0.0.1) from your phone, it works on chrome because the browser is running on the same machine as the server.
Use the local IP of your machine (e.g. 192.168.x.x) and make sure the phone/emulator is connected to the same network/wifi.
If you are running your app on a real device and using localhost in Flask, that is most likely the problem. You cannot access your PC localhost directly on your mobile.
If you are connected to your phone via a USB cable, then you can use the Google Chrome port forwarding option.
Type
chrome://inspect
in the chrome search bar and select the port forwarding option.Then set the port and IP address. In your case, do as follows
Press done, now you can use localhost in your phone.