Why this is working ?
final response = await http.get(Uri.parse("http..../?page=2"),
But this is not !
int p = 2;
String page = p.toString();
final response = await http.get(Uri.parse("http..../?page=" p),
CodePudding user response:
Do it like this
final response = await http.get(Uri.parse("http..../?page=$p"),
CodePudding user response:
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);
