Before one could pass Iterable and Dio would pass multiple parameters with the same name and with values from Iterable. Now Dio just makes toString() of iterable and passes it as value, which is not correct.
Please take an example.
Hi,
Response response = await _dio.get(
"http://domain.com/api",
queryParameters: {
"selectedId": ["1", "2"],
},
);
I am expecting to have call like this:
http://domain.com/api?selectedId=1&selectedId=2
This worked before, but not in current version
In current version, queryParameters are handled in the same way as jquery, but you can use [method]Uri API to ignore that, for example:
dio.options.baseUrl="http://domain.com/";
Response response = await dio.getUri(
Uri(path: "api",queryParameters: {
"selectedId": ["1", "2"],
})
);
Curious as to why the change was made, as it seems that the accepted way of passing multiple values for a single parameter is selectedId=1&selectedId=2 rather than selectedId[]=1&selectedId[]=2.
Most helpful comment
In current version,
queryParametersare handled in the same way as jquery, but you can use[method]UriAPI to ignore that, for example: