How to insert a parameter into the middle of a URL in flutter?
1,482
You should add all parameters to the map
var queryParameters = {
'q': cityName,
'appid': 'b6907d289e10d714a6e88b30761fae22',
};
var uri = Uri.http('samples.openweathermap.org', '/data/2.5/forecast', queryParameters);
Comments
-
Programming Learner over 1 year
I have a URL in which the parameters of the url are inserted into the middle:
(i.e,
q=Delhi, IN
https://samples.openweathermap.org/data/2.5/forecast?q=Delhi,IN&appid=b6907d289e10d714a6e88b30761fae22 )Now, in flutter I want to add the parameters dynamically which the user can input the city name, so my query string is :
var queryParameters = { 'q': cityName }; var uri = Uri.http('samples.openweathermap.org', '/data/2.5/forecast?{}''&appid=b6907d289e10d714a6e88b30761fae22', queryParameters);
but when i execute this code then the query string which i get is
How do I fix this?