flutter - 从flutter模拟器发送http请求到localhost api/win10
问题描述
我的 PC 和颤振模拟器上有 API。当我通过提琴手发布 Json 测试我的 API 时 -http://localhost:51797/test
它工作正常。
当我尝试通过颤振调用我的 API 时, var url = Uri.parse('http://localhost:51797/test');
我收到此消息
I/flutter (29903): http://localhost:51797/test E/flutter (29903): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] 未处理异常:SocketException:操作系统错误:连接被拒绝, errno = 111,地址 = 本地主机,端口 = 52824
然后我读到我必须使用var url = Uri.parse('http://10.0.2.2:51797/test');
,当我这样做时,我得到
http://10.0.2.2:51797/test E/flutter (29903): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] 未处理异常:FormatException:意外字符(在字符 1) E/flutter( 29903): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"""http://www.w3.org/TR/html...
在这里还能做些什么来解决这个问题?
解决方案
推荐阅读
- c - Linux中LoadString函数的等价物是什么?
- spring-boot - Spring boot 未从应用程序 jar 的 BOOT-INF/classes 路径加载 application.yml
- java - OneToOne 映射:违反参照完整性约束
- kubernetes - 使用 EBS 卷作为本地 Kubernetes 的存储类?
- java - Java @schduled 和休眠会话延迟
- android - 待定意图未按预期工作
- gridview - 如何在 GridView::widget 过滤器文本框上添加日历图标?
- azure - 如何在 azure devops 中转换 dev、uat、prod 环境的 .xml 文件值?
- java - Collections.sort() 方法没有正确选择重载方法
- python - 如何根据包含的文本值将熊猫数据框列拆分为多列