Reputation: 21
Why this is working?
final response = await http.get(Uri.parse("http..../?page=2"),
And this is not working?
int p = 2;
String page = p.toString();
final response = await http.get(Uri.parse("http..../?page="+p),
Upvotes: 0
Views: 390
Reputation: 594
For this purpose Uri.https has a Map<String, dynamic>? queryParameters,
property.
You can use it this way:
final p = 2;
final parameters = <String, String>{
'page': p.toString(),
};
final uri = Uri.http(
'http....com',
'/',
parameters,
);
final response = await httpClient.get(uri);
Upvotes: 1
Reputation: 244
Do it like this
final response = await http.get(Uri.parse("http..../?page=$p"),
Upvotes: 1