从 ios 台设备连接到本地主机

Connect from ios device to localhost

我的主机上有一个 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 -> 摘要中禁用了 "Sync with this iPad over Wi-Fi"。

而不是 localhost 你可以使用你当前的 ip

获取它 在命令 window 中输入:ipconfig

Note that you must be on the same network