import 'dart:convert';
// map data
var myMap = {
'id': [1, 2, 3],
'names': ['John', 'Rick', 'Carl']
}
// create url with map data in query string
Uri url = Uri.http(
'domain.com',
'/endpoint',
{
'mapData': jsonEncode(myMap),
},
);
// Print the url
print(url);
In the above code example, we have created a Map variable "myMap" that contains multiple key values. We want to send this map in the query parameter of our dart HTTP request. We are sending this map data in the request by using the jsonEncode() function and passing this map as a parameter in this function.
0 Comments