我有一个URL,其中url的参数插入到中间:
(即q=德里,IN
https://samples.openweathermap.org/data/2.5/forecast?q=Delhi,IN&appid=b6907d289e10d714a6e88b30761fae22 )
现在,在 flutter 中我想动态添加用户可以输入城市名称的参数,所以我的查询字符串是:
var queryParameters = {
'q': cityName
};
var uri = Uri.http('samples.openweathermap.org', '/data/2.5/forecast?{}''&appid=b6907d289e10d714a6e88b30761fae22', queryParameters);
但是当我执行这段代码时,我得到的查询字符串是
如何解决这个问题?
最佳答案
您应该将所有参数添加到 map
var queryParameters = {
'q': cityName,
'appid': 'b6907d289e10d714a6e88b30761fae22',
};
var uri = Uri.http('samples.openweathermap.org', '/data/2.5/forecast', queryParameters);
关于url - 如何在flutter中将参数插入URL中间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56218375/