5

What I m trying:

Open a local host in flutter WebView. I am using This plugin and this project is running in Django with URL: http://127.0.0.1:8000/. I want to open this in my flutter app.

What I have tried:

After searching SO answers, URL: http://myIPaddress:8000/.

UPDATE

I am providing internet from mobile.

This is my local IP address

I am using http://192.168.43.55:8080/ is not working and also http://192.168.43.1:8080/

Any suggestion will work, thanks.

Kurt
  • 678
  • 1
  • 7
  • 24
Sandeep Sharma
  • 639
  • 2
  • 9
  • 34
  • What's not working? `http://127.0.0.1:8000/.` is not going to work as it's localhost in the device where you run the app and not the server localhost. `http://myIPaddress:8000/.` where `myIPaddress` is the ip of the server in the same network as the device, should work unless I miss something. – Claudio Redi Jun 20 '20 at 22:29
  • `http://myIPaddress:8000/` is not working – Sandeep Sharma Jun 20 '20 at 22:34
  • Have you tested `http://myIPaddress:8000/` in desktop and mobile browser? Does it work? – Claudio Redi Jun 20 '20 at 22:35
  • Are you running / debugging in the Android emulator, the iOS simulator, on on device? In the Android emulator, you'd have to use a 10.0.2.2 based address - see https://developer.android.com/studio/run/emulator-networking. For simulator, it should work as you have it. For device, see comment above from Claudio (there may be other options, but that might be simplest). – socasanta Jun 20 '20 at 22:36
  • Yes. In desktop and mobile, nothing is working. – Sandeep Sharma Jun 20 '20 at 22:36
  • Yes, I have already gone through this. but I m using a physical device.which is my mobile and also from this device I'm providing internet to the desktop. – Sandeep Sharma Jun 20 '20 at 22:38
  • What are you using in as `myIPaddress`? if `http://127.0.0.1:8000/` works in the desktop, replacing `127.0.0.1` by a valid local ip should work too. – Claudio Redi Jun 20 '20 at 23:06
  • I have Updated the Question with `myIPaddress` but nothing works for me. – Sandeep Sharma Jun 21 '20 at 03:59

2 Answers2

4

Try with http://10.0.2.2:8000. If you get a cleartext error, in your AndroidManifest.xml add android:usesCleartextTraffic="true" under the application tag

faithomotoso
  • 385
  • 2
  • 10
0

With Android emulator, you can access the localhost by providing the IPv4 with http:// that means http://192.168.43.55:8080/ should be accessible from your flutter webview application.

Shahrukh Azeem
  • 325
  • 5
  • 10