You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
911 B
39 lines
911 B
import 'request.dart';
|
|
|
|
class Api {
|
|
/// 单例模式
|
|
static Api? _instance;
|
|
|
|
// 工厂函数:初始化,默认会返回唯一的实例
|
|
factory Api() => _instance ?? Api._internal();
|
|
|
|
// 用户Api实例:当访问UserApi的时候,就相当于使用了get方法来获取实例对象,如果_instance存在就返回_instance,不存在就初始化
|
|
static Api? get instance => _instance ?? Api._internal();
|
|
|
|
/// 初始化
|
|
Api._internal() {
|
|
// 初始化基本选项
|
|
}
|
|
|
|
$getUserData() async {
|
|
// 假设发起了请求
|
|
// var result = await Request().request(
|
|
// "xxx",
|
|
// method: DioMethod.get,
|
|
// params: data,
|
|
// isToken: true
|
|
// );
|
|
return {
|
|
"code": 200,
|
|
"data": {
|
|
"id": 1,
|
|
"nickName": "xxx",
|
|
"phone": 123123123,
|
|
"token": "xawqweqeqwqwqwe"
|
|
},
|
|
"msg": "请求成功"
|
|
};
|
|
}
|
|
|
|
|
|
}
|