[英]API and HTTP flutter data
How to Fix this error enter image description here Error: The argument type 'String' can't be assigned to the parameter type 'Uri'.如何修复此错误enter image description here错误:无法将参数类型“String”分配给参数类型“Uri”。
Error: Property 'title' cannot be accessed on 'Post?'错误:无法在“发布?”上访问属性“title” because it is potentially null.
因为它可能是 null。
You need to use Uri.parse() for parse url of api like您需要使用 Uri.parse() 来解析 url 的 api,例如
http.get(
Uri.parse('${AppConfig.apiBaseUrl}country'),
);
http
does not handle the URL strings directly starting from http: 0.13.0
. http
不处理直接从http: 0.13.0
开始的 URL 字符串。
You need to use either.您需要使用其中任何一个。
http.get(Uri.https(AppConfig.apiBaseUrl, 'country'));
or或者
http.get(Uri.parse('${AppConfig.apiBaseUrl}country'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.