我的主机上正在运行 REST 服务。在 iOS 模拟器上运行时,我可以使用以下代码从我的 flutter 应用程序执行对此服务的 HTTP 请求:
final response = await http.get('http://localhost:8085/my/service');
但是,当我在 iOS 设备上运行该应用程序时,它会失败。我的设备通过 USB 连接。
Runner[574:66922] flutter: Error SocketException: OS Error: Connection refused, errno = 61, address = localhost, port = 49575
我需要配置什么才能从我的 iOS 设备连接到本地主机?
我已在 iTunes -> 摘要中禁用“通过 Wi-Fi 与此 iPad 同步”。
最佳答案
您可以使用当前的 IP,而不是 localhost
获取它在命令窗口中输入:ipconfig
Note that you must be on the same network
关于ios - 从 ios 设备连接到 localhost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58695851/