mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-07-08 02:04:43 +08:00
add update version
This commit is contained in:
README.md
android
assets
ios
lib
pubspec.lockpubspec.yaml
24
lib/model/user_info.dart
Normal file
24
lib/model/user_info.dart
Normal file
@ -0,0 +1,24 @@
|
||||
class UserInfo {
|
||||
String username;
|
||||
int id;
|
||||
String avatarPic;
|
||||
String themeColor;
|
||||
String urlName;
|
||||
|
||||
UserInfo({
|
||||
this.avatarPic,
|
||||
this.id,
|
||||
this.themeColor,
|
||||
this.urlName,
|
||||
this.username,
|
||||
});
|
||||
|
||||
factory UserInfo.fromJson(Map<String, dynamic> json) {
|
||||
return UserInfo(
|
||||
avatarPic: json['avatar_pic'],
|
||||
id: int.parse(json['id']),
|
||||
username: json['name'],
|
||||
themeColor: json['theme_color'],
|
||||
urlName: json['url_name']);
|
||||
}
|
||||
}
|
64
lib/model/user_info_cache.dart
Normal file
64
lib/model/user_info_cache.dart
Normal file
@ -0,0 +1,64 @@
|
||||
/// @Author: 一凨
|
||||
/// @Date: 2019-01-07 16:24:42
|
||||
/// @Last Modified by: 一凨
|
||||
/// @Last Modified time: 2019-01-08 17:37:42
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_go/utils/sql.dart';
|
||||
|
||||
abstract class UserInfoInterface {
|
||||
String get username;
|
||||
String get password;
|
||||
}
|
||||
|
||||
class UserInfo implements UserInfoInterface {
|
||||
String username;
|
||||
String password;
|
||||
|
||||
UserInfo({this.username, this.password});
|
||||
|
||||
factory UserInfo.fromJSON(Map json){
|
||||
return UserInfo(username: json['username'],password: json['password']);
|
||||
}
|
||||
|
||||
Object toMap() {
|
||||
return {'username': username, 'password': password};
|
||||
}
|
||||
}
|
||||
|
||||
class UserInfoControlModel {
|
||||
final String table = 'userInfo';
|
||||
Sql sql;
|
||||
|
||||
UserInfoControlModel() {
|
||||
sql = Sql.setTable(table);
|
||||
}
|
||||
|
||||
// 获取所有的收藏
|
||||
|
||||
// 插入新的缓存
|
||||
Future insert(UserInfo userInfo) {
|
||||
var result =
|
||||
sql.insert({'username': userInfo.username, 'password': userInfo.password});
|
||||
return result;
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
Future<List<UserInfo>> getAllInfo() async {
|
||||
List list = await sql.getByCondition();
|
||||
List<UserInfo> resultList = [];
|
||||
list.forEach((item){
|
||||
print(item);
|
||||
resultList.add(UserInfo.fromJSON(item));
|
||||
});
|
||||
return resultList;
|
||||
}
|
||||
|
||||
// 清空表中数据
|
||||
Future deleteAll() async{
|
||||
return await sql.deleteAll();
|
||||
}
|
||||
|
||||
|
||||
}
|
29
lib/model/version.dart
Normal file
29
lib/model/version.dart
Normal file
@ -0,0 +1,29 @@
|
||||
class Data {
|
||||
String version;
|
||||
String name;
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json)
|
||||
: version = json['version'],
|
||||
name = json['name'];
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'name: $name ,version: $version';
|
||||
}
|
||||
}
|
||||
|
||||
class Version {
|
||||
Data data;
|
||||
int status;
|
||||
bool success;
|
||||
|
||||
Version.formJson(Map<String, dynamic> json)
|
||||
: status = json['status'],
|
||||
success = json['success'],
|
||||
data = Data.fromJson(json['data']);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'status: $status ,success: $success,date: ${data.toString()}';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user