Dio是一個Dart Http請求庫,支援Restful API、FormData、攔截器、請求取消、Cookie管理、檔案上傳/下載、逾時等。
dependencies:
dio: ^x.x.x #请使用pub上的最新版本
Response response;
response = await dio.get("/xxx");
Response response;
response = await dio.post("/xxx",data:{"id":1,"name":"Tom"});
Response response;
response = await Future.wait([dio.post("/xxx"),dio.get("/yyy")]);
Response response;
response = await dio.download("https://www.google.com/",_savePath);
FormData formData = FormData.from({
"name": "Tom",
"age": 20,
});
Response response;
response = await dio.post("/info", data: formData);