Open
Description
Package
dio
Version
5.8.0+1
Operating-System
iOS
Adapter
Default Dio
Output of flutter doctor -v
Dart Version
3.7.0
Steps to Reproduce
Original code which doesn't work:
Map data = {
'hardwareMajor': 4,
'hardwareMinor': 0,
'type': 'stable',
};
Response response = await dio.post('/native/get_last_fw_version', data: data,
options: Options(
contentType: Headers.formUrlEncodedContentType,
responseType: ResponseType.plain,
),
);
With some modification it works properly:
Map<String, String> data = {
'hardwareMajor': '4',
'hardwareMinor': '0',
'type': 'stable',
};
Response response = await dio.post('/native/get_last_fw_version', data: data,
options: Options(
contentType: Headers.formUrlEncodedContentType,
responseType: ResponseType.plain,
),
);
But as per the docs the original should work too:
// Instance level
dio.options.contentType = Headers.formUrlEncodedContentType;
// or only works once
dio.post(
'/info',
data: {'id': 5},
options: Options(contentType: Headers.formUrlEncodedContentType),
);
Expected Result
on the server:
hardwareMajor=4&hardwareMinor=0&type=stable
Actual Result
on the server:
{hardwareMajor: 4, hardwareMinor: 0, type: stable}