Flutter 之网络请求Dio, FormData, 表单网络请求, x-www-form-urlencoded

官方表单网络请求示例:

 

FormData formData = FormData.fromMap({
    "name": "wendux",
    "age": 25,
    "file": await MultipartFile.fromFile("./text.txt",filename: "upload.txt"),
    "files": [
      await MultipartFile.fromFile("./text1.txt", filename: "text1.txt"),
      await MultipartFile.fromFile("./text2.txt", filename: "text2.txt"),
    ]
 });
response = await dio.post("/info", data: formData);

// var resJson = convert.jsonDecode(res); // 字符串反序列化为Map
 
posted @ 2020-07-01 10:18  zxh91989  阅读(3942)  评论(0编辑  收藏  举报