我正在使用dio: ^3.0.4。任何人请帮我找到添加标题的解决方案。这是我的代码:
FormData formData =
new FormData.fromMap({"files": await MultipartFile.fromFile(filePath.path, filename: 'photo')
});
Response response = await dio.post("***********",
data: formData,
onSendProgress: (int sent, int total) {
print("$sent $total");
},
options: Options(
headers: {
"authorization": "*************"
},
followRedirects: false,
validateStatus: (status) {
return status <= 500;
}
),
);
当我打印标题时。
打印(response.headers);
结果:
颤振:内容类型:文本/html;charset=UTF-8 连接:关闭缓存控制:无缓存,私有传输编码:分块日期:2019 年 11 月 7 日星期四 14:29:02 GMT 服务器:Apache/2.4.18