api
class WanAndroidApi {
/// 首页banner http://www.wanandroid.com/banner/json
static const String BANNER = “banner”;
static const String USER_REGISTER = “user/register”; //注册
static const String USER_LOGIN = “user/login”; //登录
static const String USER_LOGOUT = “user/logout”; //退出
// 拼接url
static String getPath({String path: ‘’, int page, String resType: ‘json’}) {
StringBuffer sb = new StringBuffer(path);
if (page != null) {
sb.write(’/$page’);
}
if (resType != null && resType.isNotEmpty) {
sb.write(’/$resType’);
}
return sb.toString();
}
}
请求与返回实体类 protocol
class LoginReq {
String username;
String password;
LoginReq(this.username, this.password);
-
LoginReq.fromJson(Map<String, dynamic> json)
- username = json[‘username’],
password = json[‘password’];
Map<String, dynamic> toJson() => {
‘username’: username,
‘password’: password,
};
@override
String toString() {
StringBuffer sb = new StringBuffer(’{’);
sb.write("“username”:"$username"");
sb.write(",“password”:$password");
sb.write(’}’);
return sb.toString();
}
}
接口请求&解析 repository
class WanRepository {
Future<List>

本文介绍了如何使用Flutter开发WanAndroid应用程序,包括API接口、请求与返回实体类、数据存储以及屏幕适配。同时,讨论了如何在Flutter中进行蓝牙数据接收,涉及SpUtil工具类和屏幕适配库ScreenUtil的使用。
最低0.47元/天 解锁文章
579

被折叠的 条评论
为什么被折叠?



