How to point to localhost:8000 with the Dart http package in Flutter?

前端 未结 9 1087
野趣味
野趣味 2020-12-10 00:34

I\'m following the Flutter Networking/HTTP tutorial to do a GET request to a server running on my localhost:8000. Visiting my localhost via my browser works fine. My code lo

9条回答
  •  独厮守ぢ
    2020-12-10 01:25

    If you are using an Android emulator then localhost on the emulator is not 127.0.0.0 it is 10.0.2.2, so, on Android emulator you need to write https://10.0.2.2:8000, the https://127.0.0.1:8000 will not work on real device too. because localhost means something different on real device.

    For more information on how to connect a Flutter app to localhost on emulator or on a real device click on the link Connecting Flutter application to Localhost

提交回复
热议问题