1、dart库搜索dio,按文档配置
2、网络请求
get
Response response = await Dio().get(url);
print(json.decode(response));
post
Response response = await Dio().post(url2, data:{'key':'4a8edfc8ac5eae9b0c5bf08157abba96'});
print(json.decode(response));
代码示例:
var url="http://api.tianapi.com/txapi/ncov/index?key=4a8edfc8ac5eae9b0c5bf08157abba96";
get() async{
Response response = await Dio().get(url);
print(response);
}
var url2="http://api.tianapi.com/txapi/ncov/index";
post() async
{
Response response = await Dio().post(url2, data:{'key':'4a8edfc8ac5eae9b0c5bf08157abba96'});
print(response);
}