maby_dio

Last updated:

0 purchases

maby_dio Image
maby_dio Images
Add to Cart

Description:

maby dio

dio网络库封装。
Features #

download接口支持
upload接口支持
请求数据缓存支持

Getting started #
打开pubspec.yaml文件,输入:maby_dio: ^0.0.1
Usage #
普通使用 #
HttpResponse res = await HttpRequest().get('/article/today');
print(res.data?.responseData);
copied to clipboard
自定义TargetApi #
class CustomTargetApi extends TargetApi {
@override
String get baseUrl => 'your base url';
}

HttpResponse res = await HttpRequest(api: CustomTargetApi()).get('/article/today');
print(res.data?.responseData);
copied to clipboard
响应数据自动解析为模型数据 #
class CustomModel extends Codable {
String? author;
String? title;

@override
fromJson(Map<String, dynamic> json) {
author = json['author'];
title = json['title'];
}

@override
Map<String, dynamic> toJson() {
// TODO: implement toJson
throw UnimplementedError();
}
}

CustomModel model = CustomModel();
HttpResponse res = await HttpRequest(api: CustomTargetApi()).get('/article/today', model: model);
print(model.title);
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.