Browse Source

空安全升级

liuyuqi-dellpc 1 year ago
parent
commit
b43a47c0f0
58 changed files with 728 additions and 728 deletions
  1. 12 12
      lib/common/BaseArchitectural.dart
  2. 7 7
      lib/common/I18N.dart
  3. 2 2
      lib/common/LocalData.dart
  4. 3 3
      lib/common/SqfliteDataBase.dart
  5. 28 28
      lib/common/components/PopMenus.dart
  6. 6 6
      lib/common/components/SliderConfirm.dart
  7. 18 18
      lib/common/components/UserInfoPopMenuContext.dart
  8. 15 15
      lib/common/components/UserListTile.dart
  9. 2 2
      lib/common/utils/ConvertUtils.dart
  10. 7 7
      lib/common/utils/VerificationUtils.dart
  11. 15 15
      lib/database/entity/BasicInfo.dart
  12. 8 8
      lib/database/entity/ExerciseInfo.dart
  13. 7 7
      lib/database/entity/FoodInfo.dart
  14. 20 20
      lib/database/entity/LifeInfo.dart
  15. 6 6
      lib/database/entity/ScheduledExercise.dart
  16. 8 8
      lib/database/entity/SportInfo.dart
  17. 17 17
      lib/database/entity/StudyInfo.dart
  18. 77 77
      lib/network/Repository.dart
  19. 1 1
      lib/network/Status.dart
  20. 3 3
      lib/pages/home_page.dart
  21. 3 3
      lib/pages/splash_page.dart
  22. 26 26
      lib/provider/ConfigProvider.dart
  23. 68 68
      lib/provider/DataProvider.dart
  24. 15 15
      lib/provider/NotificationProvider.dart
  25. 7 7
      lib/provider/ThemeProvider.dart
  26. 25 25
      lib/provider/UserProvider.dart
  27. 2 2
      lib/view/context/BasicInfoContext.dart
  28. 6 6
      lib/view/context/ExerciseInfoContext.dart
  29. 1 1
      lib/view/context/LifeInfoContext.dart
  30. 2 2
      lib/view/context/StudyInfoContext.dart
  31. 3 3
      lib/view/context/widget/BaseCard.dart
  32. 7 7
      lib/view/context/widget/DateTimeMultiLineChart.dart
  33. 15 15
      lib/view/context/widget/DateValueMultiLineChart.dart
  34. 17 17
      lib/view/context/widget/DateValueSingleLineChart.dart
  35. 2 2
      lib/view/context/widget/StudyInfoDetailsPage.dart
  36. 5 5
      lib/view/drawer/HomePageDrawer.dart
  37. 8 8
      lib/view/drawer/community/FollowedPage.dart
  38. 7 7
      lib/view/drawer/community/RankingListPage.dart
  39. 10 10
      lib/view/drawer/community/SearchUserPage.dart
  40. 13 13
      lib/view/drawer/setting/DataManagementPage.dart
  41. 1 1
      lib/view/drawer/setting/DebugPage.dart
  42. 24 24
      lib/view/drawer/setting/SignTimeSetPage.dart
  43. 3 3
      lib/view/drawer/shop/GoodsPage.dart
  44. 4 4
      lib/view/drawer/shop/ShopPage.dart
  45. 1 1
      lib/view/drawer/user/UserPage.dart
  46. 6 6
      lib/view/drawer/user/setting/CropImagePage.dart
  47. 16 16
      lib/view/drawer/user/setting/UserSettingPage.dart
  48. 22 22
      lib/view/drawer/user/sign/ModifyPwdPage.dart
  49. 28 28
      lib/view/drawer/user/sign/SignInPage.dart
  50. 21 21
      lib/view/drawer/user/sign/SignUpPage.dart
  51. 7 7
      lib/view/record/AdjustButtonRow.dart
  52. 8 8
      lib/view/record/BasicInfoRecordingPage.dart
  53. 14 14
      lib/view/record/ExerciseInfoRecordingPage.dart
  54. 26 26
      lib/view/record/LifeInfoRecordingPage.dart
  55. 19 19
      lib/view/record/StudyInfoRecordingPage.dart
  56. 12 12
      lib/view/record/sub/AddScheduledExercisePage.dart
  57. 11 11
      lib/view/record/sub/FoodRecordPage.dart
  58. 1 1
      pubspec.yaml

+ 12 - 12
lib/common/BaseArchitectural.dart

@@ -39,7 +39,7 @@ class {ENTITY_NAME}Mapper extends CommonMapper<{ENTITY_NAME}> {
 }
  */
 abstract class CommonMapper<T extends dynamic> {
-  dynamic _currentTypeInstance;
+  late dynamic _currentTypeInstance;
 
 
   CommonMapper(dynamic entityI) {
@@ -71,7 +71,7 @@ abstract class CommonMapper<T extends dynamic> {
   // C
   Future<bool> insert(T entity) async {
     try {
-      Database database = SqfliteDataBase.getInstance();
+      Database database = SqfliteDataBase.getInstance()!;
       await database.insert(_currentTypeInstance.tableName, entity.value);
       debugPrint("[CommonMapper] insert: ${entity.toString()}");
       return true;
@@ -82,9 +82,9 @@ abstract class CommonMapper<T extends dynamic> {
   }
 
   // R
-  Future<List<T>> selectAll({int limit, String orderBy}) async {
+  Future<List<T>?> selectAll({int? limit, String? orderBy}) async {
     try {
-      Database database = SqfliteDataBase.getInstance();
+      Database database = SqfliteDataBase.getInstance()!;
       List<Map<String, dynamic>> dbResult = await database.query(
         _currentTypeInstance.tableName,
         limit: limit,
@@ -99,10 +99,10 @@ abstract class CommonMapper<T extends dynamic> {
     }
   }
 
-  Future<List<T>> selectWhere(String where,
-      {int limit, String orderBy}) async {
+  Future<List<T>?> selectWhere(String where,
+      {int? limit, String? orderBy}) async {
     try {
-      Database database = SqfliteDataBase.getInstance();
+      Database database = SqfliteDataBase.getInstance()!;
       List<Map<String, dynamic>> dbResult = await database.query(
         _currentTypeInstance.tableName,
         limit: limit,
@@ -117,10 +117,10 @@ abstract class CommonMapper<T extends dynamic> {
     }
   }
 
-  Future<List<T>> selectMatchBy(dynamic entity,
-      {int limit, String orderBy}) async {
+  Future<List<T>?> selectMatchBy(dynamic entity,
+      {int? limit, String? orderBy}) async {
     try {
-      Database database = SqfliteDataBase.getInstance();
+      Database database = SqfliteDataBase.getInstance()!;
 
       String matches = "";
       entity.value.forEach((key, value) {
@@ -165,7 +165,7 @@ abstract class CommonMapper<T extends dynamic> {
 
   Future<bool> updateByFirstKeySelective(T entity) async {
     try {
-      Database database = SqfliteDataBase.getInstance();
+      Database database = SqfliteDataBase.getInstance()!;
 
       entity.value.removeWhere((_, value) {
         return value == null;
@@ -184,7 +184,7 @@ abstract class CommonMapper<T extends dynamic> {
 
   // D
   Future<int> delete(T entity) async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
 
     String matches = "";
     entity.value.forEach((key, value) {

+ 7 - 7
lib/common/I18N.dart

@@ -4,28 +4,28 @@ import 'package:flutter_habit/common/LocalData.dart';
 /// Time       : 08/18/2023 Friday
 /// Author     : liuyuqi.gov@msn.cn
 class I18N {
-  static String _language;
+  static String? _language;
 
   static void init() {
-    _language = LocalData.getInstance().getString("language");
+    _language = LocalData.getInstance()!.getString("language");
     if (_language == null) {
       _language = "cn";
-      LocalData.getInstance().setString("language", _language);
+      LocalData.getInstance()!.setString("language", _language!);
     }
     debugPrint("init I18N to $_language");
   }
 
-  static String of(String key) {
-    return wordMap[_language][key] ?? "${_language.toUpperCase()}_$key";
+  static String of(String? key) {
+    return wordMap[_language]![key] ?? "${_language!.toUpperCase()}_$key";
   }
 
-  static String getLanguage() {
+  static String? getLanguage() {
     return _language;
   }
 
   static void setLanguage(String language) {
     _language = language;
-    LocalData.getInstance().setString("language", _language);
+    LocalData.getInstance()!.setString("language", _language!);
   }
 }
 

+ 2 - 2
lib/common/LocalData.dart

@@ -5,7 +5,7 @@ import 'package:shared_preferences/shared_preferences.dart';
 /// Time       : 08/18/2023 Friday
 /// Author     : liuyuqi.gov@msn.cn
 class LocalData {
-  static SharedPreferences _sharedPreferences;
+  static SharedPreferences? _sharedPreferences;
   static init() async {
     if (_sharedPreferences == null) {
       _sharedPreferences = await SharedPreferences.getInstance();
@@ -13,7 +13,7 @@ class LocalData {
     }
   }
 
-  static SharedPreferences getInstance() {
+  static SharedPreferences? getInstance() {
     return _sharedPreferences;
   }
 }

+ 3 - 3
lib/common/SqfliteDataBase.dart

@@ -11,10 +11,10 @@ import 'package:sqflite/sqflite.dart';
 class SqfliteDataBase {
 
   static final String dbPath = "repository.db.sql";
-  static Database _database;
+  static Database? _database;
 
   static Future<void> init() async {
-    if (_database == null || !_database.isOpen) {
+    if (_database == null || !_database!.isOpen) {
       String databasesPath = "${await getDatabasesPath()}/$dbPath";
       _database = await openDatabase(databasesPath, version: 1);
       await _createTablesIfExists();
@@ -22,7 +22,7 @@ class SqfliteDataBase {
     }
   }
 
-  static Database getInstance() {
+  static Database? getInstance() {
     return _database;
   }
 

+ 28 - 28
lib/common/components/PopMenus.dart

@@ -8,9 +8,9 @@ import 'UserInfoPopMenuContext.dart';
 
 class PopMenus {
   static Future<void> confirm({
-    @required BuildContext context,
-    Widget content,
-    @required Function function,
+    required BuildContext context,
+    Widget? content,
+    required Function function,
   }) async {
     await baseAlertMenu<int>(
       context: context,
@@ -33,14 +33,14 @@ class PopMenus {
       if (value == 1) {
         function();
       }
-      return value;
+      return value!;
     });
   }
 
   static Future<void> sliderConfirm({
-    @required BuildContext context,
-    Widget content,
-    @required Function function,
+    required BuildContext context,
+    Widget? content,
+    required Function function,
   }) async {
     await baseMenu<int>(
       context: context,
@@ -48,7 +48,7 @@ class PopMenus {
         Padding(
           padding: EdgeInsets.all(24),
           child: DefaultTextStyle(
-            style: Theme.of(context).textTheme.titleLarge,
+            style: Theme.of(context).textTheme.titleLarge!,
             child: content ?? Text(I18N.of("继续该操作吗?")),
           ),
         ),
@@ -64,13 +64,13 @@ class PopMenus {
       if (value == 1) {
         function();
       }
-      return value;
+      return value!;
     });
   }
 
   static Future<void> attention({
-    @required BuildContext context,
-    Widget content,
+    required BuildContext context,
+    Widget? content,
   }) async {
     await baseAlertMenu(
       context: context,
@@ -78,11 +78,11 @@ class PopMenus {
     );
   }
 
-  static Future<T> baseAlertMenu<T>({
-    @required BuildContext context,
-    Widget title,
-    Widget content,
-    List<Widget> actions,
+  static Future<T?> baseAlertMenu<T>({
+    required BuildContext context,
+    Widget? title,
+    Widget? content,
+    List<Widget>? actions,
   }) async {
     return await showDialog(
       context: context,
@@ -102,11 +102,11 @@ class PopMenus {
     );
   }
 
-  static Future<T> baseMenu<T>({
-    @required BuildContext context,
-    Widget title,
-    List<Widget> children,
-    EdgeInsetsGeometry contentPadding,
+  static Future<T?> baseMenu<T>({
+    required BuildContext context,
+    Widget? title,
+    List<Widget>? children,
+    EdgeInsetsGeometry? contentPadding,
   }) async {
     return await showDialog(
       context: context,
@@ -120,7 +120,7 @@ class PopMenus {
   }
 
   static Future<String> datePicker({
-    @required BuildContext context,
+    required BuildContext context,
   }) async {
     return await showDatePicker(
       context: context,
@@ -136,9 +136,9 @@ class PopMenus {
     });
   }
 
-  static Future<String> userInfo({
-    @required BuildContext context,
-    @required int uid,
+  static Future<String?> userInfo({
+    required BuildContext context,
+    required int? uid,
   }) async {
     return await baseMenu(
       context: context,
@@ -178,8 +178,8 @@ class PopMenus {
   }
 
   static Future<void> coinAdd({
-    @required BuildContext context,
-    @required int addedCoins,
+    required BuildContext context,
+    required int addedCoins,
   }) async {
     await baseMenu(
       context: context,
@@ -212,7 +212,7 @@ class PopMenus {
         Container(height: 10,),
         Center(
           child: Text(
-            "${Provider.of<UserProvider>(context, listen: false).coins} -> ${Provider.of<UserProvider>(context, listen: false).coins + addedCoins}",
+            "${Provider.of<UserProvider>(context, listen: false).coins} -> ${Provider.of<UserProvider>(context, listen: false).coins! + addedCoins}",
             style: TextStyle(
               color: Theme.of(context).unselectedWidgetColor,
             ),

+ 6 - 6
lib/common/components/SliderConfirm.dart

@@ -4,16 +4,16 @@ import 'package:flutter_habit/common/I18N.dart';
 class SliderConfirm extends StatefulWidget {
   final Function function;
 
-  SliderConfirm({@required this.function});
+  SliderConfirm({required this.function});
 
   @override
   _SliderConfirmState createState() => _SliderConfirmState();
 }
 
 class _SliderConfirmState extends State<SliderConfirm> {
-  double currentValue;
-  bool isEnd;
-  bool isFormStart;
+  double? currentValue;
+  late bool isEnd;
+  late bool isFormStart;
 
   @override
   void initState() {
@@ -37,7 +37,7 @@ class _SliderConfirmState extends State<SliderConfirm> {
             child: Slider(
               activeColor: Theme.of(context).colorScheme.secondary,
               inactiveColor: Colors.transparent,
-              value: currentValue,
+              value: currentValue!,
               min: 0,
               max: 1,
               onChanged: (value) {
@@ -70,7 +70,7 @@ class _SliderConfirmState extends State<SliderConfirm> {
                   I18N.of("松开以继续"),
                   style: Theme.of(context)
                       .textTheme
-                      .titleSmall
+                      .titleSmall!
                       .copyWith(color: Theme.of(context).colorScheme.secondary),
                 )
               : Text(

+ 18 - 18
lib/common/components/UserInfoPopMenuContext.dart

@@ -7,7 +7,7 @@ import 'package:flutter_habit/network/Repository.dart';
 import 'package:provider/provider.dart';
 
 class UserInfoPopMenuContext extends StatefulWidget {
-  final int uid;
+  final int? uid;
 
   UserInfoPopMenuContext(this.uid);
 
@@ -16,11 +16,11 @@ class UserInfoPopMenuContext extends StatefulWidget {
 }
 
 class _UserInfoPopMenuContextState extends State<UserInfoPopMenuContext> {
-  List<int> photo;
-  Map userInfo;
-  int coins;
+  List<int>? photo;
+  Map? userInfo;
+  int? coins;
 
-  bool isFollowed;
+  bool? isFollowed;
 
   @override
   void initState() {
@@ -36,14 +36,14 @@ class _UserInfoPopMenuContextState extends State<UserInfoPopMenuContext> {
   Future<void> getData() async {
     UserProvider userProvider =
         Provider.of<UserProvider>(context, listen: false);
-    isFollowed = await Repository.getInstance().getFollowState(
+    isFollowed = await Repository.getInstance()!.getFollowState(
         context, userProvider.token, userProvider.uid, widget.uid);
     setState(() {});
-    userInfo = await Repository.getInstance().getUserInfo(widget.uid);
+    userInfo = await Repository.getInstance()!.getUserInfo(widget.uid);
     setState(() {});
-    coins = await Repository.getInstance().getCoin(widget.uid);
+    coins = await Repository.getInstance()!.getCoin(widget.uid);
     setState(() {});
-    photo = await Repository.getInstance().getPhoto(widget.uid);
+    photo = await Repository.getInstance()!.getPhoto(widget.uid);
     setState(() {});
   }
 
@@ -57,7 +57,7 @@ class _UserInfoPopMenuContextState extends State<UserInfoPopMenuContext> {
           mainAxisAlignment: MainAxisAlignment.spaceBetween,
           crossAxisAlignment: CrossAxisAlignment.center,
           children: <Widget>[
-            photo == null || photo.isEmpty
+            photo == null || photo!.isEmpty
                 ? Icon(
                     Icons.account_circle,
                     size: size,
@@ -65,7 +65,7 @@ class _UserInfoPopMenuContextState extends State<UserInfoPopMenuContext> {
                   )
                 : ClipOval(
                     child: Image.memory(
-                      photo,
+                      photo as Uint8List,
                       width: size,
                       height: size,
                     ),
@@ -84,15 +84,15 @@ class _UserInfoPopMenuContextState extends State<UserInfoPopMenuContext> {
               children: <Widget>[
                 userInfo == null
                     ? Text(I18N.of("用户名"))
-                    : Text(userInfo["userName"].toString(),
+                    : Text(userInfo!["userName"].toString(),
                         style: TextStyle(height: 1.5)),
                 userInfo == null
                     ? Text(I18N.of("生日"))
-                    : Text(userInfo["birthday"].toString(),
+                    : Text(userInfo!["birthday"].toString(),
                         style: TextStyle(height: 1.5)),
                 userInfo == null
                     ? Text(I18N.of("性别"))
-                    : Text(I18N.of(userInfo["gender"].toString()),
+                    : Text(I18N.of(userInfo!["gender"].toString()),
                         style: TextStyle(height: 1.5)),
                 Text(coins.toString(), style: TextStyle(height: 1.5)),
               ],
@@ -105,7 +105,7 @@ class _UserInfoPopMenuContextState extends State<UserInfoPopMenuContext> {
           children: <Widget>[
             ElevatedButton(
               style: ButtonStyle(
-                  backgroundColor: MaterialStateProperty.all(isFollowed
+                  backgroundColor: MaterialStateProperty.all(isFollowed!
                       ? Theme.of(context).unselectedWidgetColor
                       : Theme.of(context).colorScheme.secondary),
                   foregroundColor:
@@ -113,14 +113,14 @@ class _UserInfoPopMenuContextState extends State<UserInfoPopMenuContext> {
                   shape: MaterialStateProperty.all(RoundedRectangleBorder(
                     borderRadius: BorderRadius.circular(5.0),
                   ))),
-              child: isFollowed ? Text(I18N.of("取消关注")) : Text(I18N.of("关注")),
+              child: isFollowed! ? Text(I18N.of("取消关注")) : Text(I18N.of("关注")),
               onPressed: () async {
                 UserProvider userProvider =
                     Provider.of<UserProvider>(context, listen: false);
-                String res = await Repository.getInstance().follow(
+                String? res = await Repository.getInstance()!.follow(
                     context, userProvider.token, userProvider.uid, widget.uid);
                 if (res != null) {
-                  isFollowed = !isFollowed;
+                  isFollowed = !isFollowed!;
                   setState(() {});
                   await PopMenus.attention(
                       context: context,

+ 15 - 15
lib/common/components/UserListTile.dart

@@ -7,20 +7,20 @@ import 'package:provider/provider.dart';
 
 
 class UserListTile extends StatefulWidget {
-  final int uid;
-  final Widget trailing;
-  final Function onPress;
+  final int? uid;
+  final Widget? trailing;
+  final Function? onPress;
 
-  UserListTile({@required this.uid, this.onPress, this.trailing});
+  UserListTile({required this.uid, this.onPress, this.trailing});
 
   @override
   _UserListTileState createState() => _UserListTileState();
 }
 
 class _UserListTileState extends State<UserListTile> {
-  List<int> photo;
-  Map userInfo;
-  int coins;
+  List<int>? photo;
+  Map? userInfo;
+  int? coins;
 
   @override
   void initState() {
@@ -36,15 +36,15 @@ class _UserListTileState extends State<UserListTile> {
     UserProvider userProvider =
         Provider.of<UserProvider>(context, listen: false);
     if (widget.uid == userProvider.uid) {
-      userInfo["userName"] = userProvider.userName;
+      userInfo!["userName"] = userProvider.userName;
       photo = userProvider.photo;
       coins = userProvider.coins;
     } else {
-      userInfo = await Repository.getInstance().getUserInfo(widget.uid);
+      userInfo = await Repository.getInstance()!.getUserInfo(widget.uid);
       setState(() {});
-      coins = await Repository.getInstance().getCoin(widget.uid);
+      coins = await Repository.getInstance()!.getCoin(widget.uid);
       setState(() {});
-      photo = await Repository.getInstance().getPhoto(widget.uid);
+      photo = await Repository.getInstance()!.getPhoto(widget.uid);
     }
     setState(() {});
   }
@@ -53,7 +53,7 @@ class _UserListTileState extends State<UserListTile> {
   Widget build(BuildContext context) {
     double previewSize = 50;
     return ListTile(
-      leading: photo == null || photo.isEmpty
+      leading: photo == null || photo!.isEmpty
           ? Icon(
               Icons.account_circle,
               size: previewSize,
@@ -61,7 +61,7 @@ class _UserListTileState extends State<UserListTile> {
             )
           : ClipOval(
               child: Image.memory(
-                photo,
+                photo as Uint8List,
                 width: previewSize,
                 height: previewSize,
               ),
@@ -69,7 +69,7 @@ class _UserListTileState extends State<UserListTile> {
       title: userInfo == null
           ? Text(I18N.of("用户名"))
           : Text(
-              userInfo["userName"].toString(),
+              userInfo!["userName"].toString(),
               style: widget.uid !=
                   Provider.of<UserProvider>(context, listen: false).uid ? null : TextStyle(
                 decoration: TextDecoration.underline,
@@ -78,7 +78,7 @@ class _UserListTileState extends State<UserListTile> {
             ),
       subtitle: Text("${I18N.of("金币")} : ${coins.toString()}"),
       trailing: widget.trailing ?? Icon(Icons.info_outline),
-      onTap: Provider.of<UserProvider>(context, listen: false).token == null ? null:  widget.onPress,
+      onTap: Provider.of<UserProvider>(context, listen: false).token == null ? null:  widget.onPress as void Function()?,
     );
   }
 }

+ 2 - 2
lib/common/utils/ConvertUtils.dart

@@ -5,7 +5,7 @@ import 'package:flutter_habit/common/I18N.dart';
 class ConvertUtils {
   static int offset = DateTime.now().timeZoneOffset.inMilliseconds;
 
-  static String packString(Object s) {
+  static String packString(Object? s) {
     return s == null ? I18N.of("无数据") : s.toString();
   }
 
@@ -48,7 +48,7 @@ class ConvertUtils {
   }
 
   static double fixedDouble(double value, int fix) {
-    int fixNum = pow(10, fix);
+    int fixNum = pow(10, fix) as int;
     return (value * fixNum).round() / fixNum;
   }
 }

+ 7 - 7
lib/common/utils/VerificationUtils.dart

@@ -6,38 +6,38 @@ class VerifyUtils {
   static final RegExp _regexPassword =
       RegExp("^(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9#?!@\$%^&*,]{8,16}\$");
 
-  static bool isUserName(String s) {
+  static bool isUserName(String? s) {
     if (s == null || s.isEmpty) {
       return false;
     }
     return _regexUserName.hasMatch(s);
   }
 
-  static bool isEmail(String s) {
+  static bool isEmail(String? s) {
     if (s == null || s.isEmpty) {
       return false;
     }
     return _regexEmail.hasMatch(s);
   }
 
-  static bool isPassword(String s) {
+  static bool isPassword(String? s) {
     if (s == null || s.isEmpty) {
       return false;
     }
     return _regexPassword.hasMatch(s);
   }
 
-  static bool nowIsBetweenTime(int a, int b) {
+  static bool nowIsBetweenTime(int a, int? b) {
     DateTime now = DateTime.now();
     DateTime nowTime = DateTime(1, 1, 1, now.hour, now.minute, now.second);
     return a <= nowTime.millisecondsSinceEpoch &&
-        nowTime.millisecondsSinceEpoch <= b;
+        nowTime.millisecondsSinceEpoch <= b!;
   }
 
-  static bool isBetweenTime(int a, int v, int b) {
+  static bool isBetweenTime(int a, int v, int? b) {
     DateTime vTime = DateTime.fromMillisecondsSinceEpoch(v);
     DateTime nowTime = DateTime(1, 1, 1, vTime.hour, vTime.minute, vTime.second);
     return a <= nowTime.millisecondsSinceEpoch &&
-        nowTime.millisecondsSinceEpoch <= b;
+        nowTime.millisecondsSinceEpoch <= b!;
   }
 }

+ 15 - 15
lib/database/entity/BasicInfo.dart

@@ -14,7 +14,7 @@ class BasicInfo {
     "date" : null,
   };
   static Future<void> create() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
       CREATE TABLE IF NOT EXISTS basicInfo (  
         id INTEGER PRIMARY KEY AUTOINCREMENT ,
@@ -30,7 +30,7 @@ class BasicInfo {
   }
   
   static Future<void> recreate() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
     DROP TABLE IF EXISTS basicInfo;
     """);
@@ -46,61 +46,61 @@ class BasicInfo {
     }).toList();
   }
   
-  int getId() {
+  int? getId() {
     return value["id"];
   }
 
-  BasicInfo setId(int id) {
+  BasicInfo setId(int? id) {
     value["id"] = id;
     return this;
   }
   
-  double getHeight() {
+  double? getHeight() {
     return value["height"];
   }
 
-  BasicInfo setHeight(double height) {
+  BasicInfo setHeight(double? height) {
     value["height"] = height;
     return this;
   }
   
-  double getWeight() {
+  double? getWeight() {
     return value["weight"];
   }
 
-  BasicInfo setWeight(double weight) {
+  BasicInfo setWeight(double? weight) {
     value["weight"] = weight;
     return this;
   }
   
-  double getBreastLine() {
+  double? getBreastLine() {
     return value["breastLine"];
   }
 
-  BasicInfo setBreastLine(double cheatLine) {
+  BasicInfo setBreastLine(double? cheatLine) {
     value["breastLine"] = cheatLine;
     return this;
   }
   
-  double getWaistLine() {
+  double? getWaistLine() {
     return value["waistLine"];
   }
 
-  BasicInfo setWaistLine(double waistLine) {
+  BasicInfo setWaistLine(double? waistLine) {
     value["waistLine"] = waistLine;
     return this;
   }
   
-  double getHipLine() {
+  double? getHipLine() {
     return value["hipLine"];
   }
 
-  BasicInfo setHipLine(double hipLine) {
+  BasicInfo setHipLine(double? hipLine) {
     value["hipLine"] = hipLine;
     return this;
   }
   
-  int getDate() {
+  int? getDate() {
     return value["date"];
   }
 

+ 8 - 8
lib/database/entity/ExerciseInfo.dart

@@ -11,7 +11,7 @@ class ExerciseInfo {
     "exerciseQuantity" : null,
   };
   static Future<void> create() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
       CREATE TABLE IF NOT EXISTS exerciseInfo (  
         id INTEGER PRIMARY KEY AUTOINCREMENT ,
@@ -24,7 +24,7 @@ class ExerciseInfo {
   }
   
   static Future<void> recreate() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
     DROP TABLE IF EXISTS exerciseInfo;
     """);
@@ -40,7 +40,7 @@ class ExerciseInfo {
     }).toList();
   }
   
-  int getId() {
+  int? getId() {
     return value["id"];
   }
 
@@ -49,16 +49,16 @@ class ExerciseInfo {
     return this;
   }
   
-  int getSportId() {
+  int? getSportId() {
     return value["sportId"];
   }
 
-  ExerciseInfo setSportId(int sportId) {
+  ExerciseInfo setSportId(int? sportId) {
     value["sportId"] = sportId;
     return this;
   }
   
-  int getExerciseTime() {
+  int? getExerciseTime() {
     return value["exerciseTime"];
   }
 
@@ -67,11 +67,11 @@ class ExerciseInfo {
     return this;
   }
   
-  double getExerciseQuantity() {
+  double? getExerciseQuantity() {
     return value["exerciseQuantity"];
   }
 
-  ExerciseInfo setExerciseQuantity(double exerciseQuantity) {
+  ExerciseInfo setExerciseQuantity(double? exerciseQuantity) {
     value["exerciseQuantity"] = exerciseQuantity;
     return this;
   }

+ 7 - 7
lib/database/entity/FoodInfo.dart

@@ -11,7 +11,7 @@ class FoodInfo {
     "eatTimes" : null,
   };
   static Future<void> create() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
       CREATE TABLE IF NOT EXISTS foodInfo (  
         id INTEGER PRIMARY KEY AUTOINCREMENT ,
@@ -24,7 +24,7 @@ class FoodInfo {
   }
   
   static Future<void> recreate() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
     DROP TABLE IF EXISTS foodInfo;
     """);
@@ -40,7 +40,7 @@ class FoodInfo {
     }).toList();
   }
   
-  int getId() {
+  int? getId() {
     return value["id"];
   }
 
@@ -49,7 +49,7 @@ class FoodInfo {
     return this;
   }
   
-  String getName() {
+  String? getName() {
     return value["name"];
   }
 
@@ -58,7 +58,7 @@ class FoodInfo {
     return this;
   }
   
-  double getHgkCalorie() {
+  double? getHgkCalorie() {
     return value["gkCalorie"];
   }
 
@@ -67,11 +67,11 @@ class FoodInfo {
     return this;
   }
   
-  int getEatTimes() {
+  int? getEatTimes() {
     return value["eatTimes"];
   }
 
-  FoodInfo setEatTimes(int eatTimes) {
+  FoodInfo setEatTimes(int? eatTimes) {
     value["eatTimes"] = eatTimes;
     return this;
   }

+ 20 - 20
lib/database/entity/LifeInfo.dart

@@ -24,7 +24,7 @@ class LifeInfo {
     "restTime" : null,
   };
   static Future<void> create() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
       CREATE TABLE IF NOT EXISTS lifeInfo (  
         id INTEGER PRIMARY KEY AUTOINCREMENT ,
@@ -50,7 +50,7 @@ class LifeInfo {
   }
   
   static Future<void> recreate() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
     DROP TABLE IF EXISTS lifeInfo;
     """);
@@ -66,16 +66,16 @@ class LifeInfo {
     }).toList();
   }
   
-  int getId() {
+  int? getId() {
     return value["id"];
   }
 
-  LifeInfo setId(int id) {
+  LifeInfo setId(int? id) {
     value["id"] = id;
     return this;
   }
   
-  int getDate() {
+  int? getDate() {
     return value["date"];
   }
 
@@ -84,7 +84,7 @@ class LifeInfo {
     return this;
   }
   
-  int getGetUpTime() {
+  int? getGetUpTime() {
     return value["getUpTime"];
   }
 
@@ -93,7 +93,7 @@ class LifeInfo {
     return this;
   }
   
-  int getBreakfastTime() {
+  int? getBreakfastTime() {
     return value["breakfastTime"];
   }
 
@@ -102,7 +102,7 @@ class LifeInfo {
     return this;
   }
   
-  int getBreakfastId() {
+  int? getBreakfastId() {
     return value["breakfastId"];
   }
 
@@ -111,7 +111,7 @@ class LifeInfo {
     return this;
   }
   
-  double getBreakfastQuantity() {
+  double? getBreakfastQuantity() {
     return value["breakfastQuantity"];
   }
 
@@ -120,7 +120,7 @@ class LifeInfo {
     return this;
   }
   
-  double getBreakfastMoney() {
+  double? getBreakfastMoney() {
     return value["breakfastMoney"];
   }
 
@@ -129,7 +129,7 @@ class LifeInfo {
     return this;
   }
   
-  int getMidRestTime() {
+  int? getMidRestTime() {
     return value["midRestTime"];
   }
 
@@ -138,7 +138,7 @@ class LifeInfo {
     return this;
   }
   
-  int getLunchTime() {
+  int? getLunchTime() {
     return value["lunchTime"];
   }
 
@@ -147,7 +147,7 @@ class LifeInfo {
     return this;
   }
   
-  int getLunchId() {
+  int? getLunchId() {
     return value["lunchId"];
   }
 
@@ -156,7 +156,7 @@ class LifeInfo {
     return this;
   }
   
-  double getLunchQuantity() {
+  double? getLunchQuantity() {
     return value["lunchQuantity"];
   }
 
@@ -165,7 +165,7 @@ class LifeInfo {
     return this;
   }
   
-  double getLunchMoney() {
+  double? getLunchMoney() {
     return value["lunchMoney"];
   }
 
@@ -174,7 +174,7 @@ class LifeInfo {
     return this;
   }
   
-  int getDinnerTime() {
+  int? getDinnerTime() {
     return value["dinnerTime"];
   }
 
@@ -183,7 +183,7 @@ class LifeInfo {
     return this;
   }
   
-  int getDinnerId() {
+  int? getDinnerId() {
     return value["dinnerId"];
   }
 
@@ -192,7 +192,7 @@ class LifeInfo {
     return this;
   }
   
-  double getDinnerQuantity() {
+  double? getDinnerQuantity() {
     return value["dinnerQuantity"];
   }
 
@@ -201,7 +201,7 @@ class LifeInfo {
     return this;
   }
   
-  double getDinnerMoney() {
+  double? getDinnerMoney() {
     return value["dinnerMoney"];
   }
 
@@ -210,7 +210,7 @@ class LifeInfo {
     return this;
   }
   
-  int getRestTime() {
+  int? getRestTime() {
     return value["restTime"];
   }
 

+ 6 - 6
lib/database/entity/ScheduledExercise.dart

@@ -10,7 +10,7 @@ class ScheduledExercise {
     "quantity" : null,
   };
   static Future<void> create() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
       CREATE TABLE IF NOT EXISTS scheduledExercise (  
         id INTEGER PRIMARY KEY AUTOINCREMENT ,
@@ -22,7 +22,7 @@ class ScheduledExercise {
   }
   
   static Future<void> recreate() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
     DROP TABLE IF EXISTS scheduledExercise;
     """);
@@ -38,7 +38,7 @@ class ScheduledExercise {
     }).toList();
   }
   
-  int getId() {
+  int? getId() {
     return value["id"];
   }
 
@@ -47,16 +47,16 @@ class ScheduledExercise {
     return this;
   }
   
-  int getSportId() {
+  int? getSportId() {
     return value["sportId"];
   }
 
-  ScheduledExercise setSportId(int sportId) {
+  ScheduledExercise setSportId(int? sportId) {
     value["sportId"] = sportId;
     return this;
   }
   
-  double getQuantity() {
+  double? getQuantity() {
     return value["quantity"];
   }
 

+ 8 - 8
lib/database/entity/SportInfo.dart

@@ -11,7 +11,7 @@ class SportInfo {
     "sportTimes" : null,
   };
   static Future<void> create() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
       CREATE TABLE IF NOT EXISTS sportInfo (  
         id INTEGER PRIMARY KEY AUTOINCREMENT ,
@@ -24,7 +24,7 @@ class SportInfo {
   }
   
   static Future<void> recreate() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
     DROP TABLE IF EXISTS sportInfo;
     """);
@@ -40,16 +40,16 @@ class SportInfo {
     }).toList();
   }
   
-  int getId() {
+  int? getId() {
     return value["id"];
   }
 
-  SportInfo setId(int id) {
+  SportInfo setId(int? id) {
     value["id"] = id;
     return this;
   }
   
-  String getName() {
+  String? getName() {
     return value["name"];
   }
 
@@ -58,7 +58,7 @@ class SportInfo {
     return this;
   }
   
-  double getHkCalorie() {
+  double? getHkCalorie() {
     return value["hkCalorie"];
   }
 
@@ -67,11 +67,11 @@ class SportInfo {
     return this;
   }
   
-  int getSportTimes() {
+  int? getSportTimes() {
     return value["sportTimes"];
   }
 
-  SportInfo setSportTimes(int sportTimes) {
+  SportInfo setSportTimes(int? sportTimes) {
     value["sportTimes"] = sportTimes;
     return this;
   }

+ 17 - 17
lib/database/entity/StudyInfo.dart

@@ -17,7 +17,7 @@ class StudyInfo {
     "troubles" : null,
   };
   static Future<void> create() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
       CREATE TABLE IF NOT EXISTS studyInfo (  
         id INTEGER PRIMARY KEY AUTOINCREMENT ,
@@ -36,7 +36,7 @@ class StudyInfo {
   }
   
   static Future<void> recreate() async {
-    Database database = SqfliteDataBase.getInstance();
+    Database database = SqfliteDataBase.getInstance()!;
     await database.execute("""
     DROP TABLE IF EXISTS studyInfo;
     """);
@@ -52,16 +52,16 @@ class StudyInfo {
     }).toList();
   }
   
-  int getId() {
+  int? getId() {
     return value["id"];
   }
 
-  StudyInfo setId(int id) {
+  StudyInfo setId(int? id) {
     value["id"] = id;
     return this;
   }
   
-  int getDate() {
+  int? getDate() {
     return value["date"];
   }
 
@@ -70,7 +70,7 @@ class StudyInfo {
     return this;
   }
   
-  String getCourseName() {
+  String? getCourseName() {
     return value["courseName"];
   }
 
@@ -79,34 +79,34 @@ class StudyInfo {
     return this;
   }
   
-  int getIsLate() {
+  int? getIsLate() {
     return value["isLate"];
   }
 
-  StudyInfo setIsLate(int isLate) {
+  StudyInfo setIsLate(int? isLate) {
     value["isLate"] = isLate;
     return this;
   }
   
-  int getIsAbsent() {
+  int? getIsAbsent() {
     return value["isAbsent"];
   }
 
-  StudyInfo setIsAbsent(int isAbsent) {
+  StudyInfo setIsAbsent(int? isAbsent) {
     value["isAbsent"] = isAbsent;
     return this;
   }
   
-  int getIsHomeWorkDone() {
+  int? getIsHomeWorkDone() {
     return value["isHomeWorkDone"];
   }
 
-  StudyInfo setIsHomeWorkDone(int isHomeWorkDone) {
+  StudyInfo setIsHomeWorkDone(int? isHomeWorkDone) {
     value["isHomeWorkDone"] = isHomeWorkDone;
     return this;
   }
   
-  String getHomeworks() {
+  String? getHomeworks() {
     return value["homeworks"];
   }
 
@@ -115,16 +115,16 @@ class StudyInfo {
     return this;
   }
   
-  int getDifficulty() {
+  int? getDifficulty() {
     return value["difficulty"];
   }
 
-  StudyInfo setDifficulty(int difficulty) {
+  StudyInfo setDifficulty(int? difficulty) {
     value["difficulty"] = difficulty;
     return this;
   }
   
-  int getIsTroublesSolved() {
+  int? getIsTroublesSolved() {
     return value["isTroublesSolved"];
   }
 
@@ -133,7 +133,7 @@ class StudyInfo {
     return this;
   }
   
-  String getTroubles() {
+  String? getTroubles() {
     return value["troubles"];
   }
 

+ 77 - 77
lib/network/Repository.dart

@@ -10,7 +10,7 @@ import 'api.dart';
 import 'Status.dart';
 
 class Repository {
-  Dio _dio;
+  Dio? _dio;
 
   Repository._() {
     if (_dio == null) {
@@ -23,9 +23,9 @@ class Repository {
     }
   }
 
-  static Repository _repository;
+  static Repository? _repository;
 
-  static Repository getInstance() {
+  static Repository? getInstance() {
     if (_repository == null) {
       _repository = Repository._();
     }
@@ -37,9 +37,9 @@ class Repository {
     String email,
     String purpose,
   ) async {
-    Response response;
+    Response? response;
     try {
-      response = await _dio.post(
+      response = await _dio!.post(
         Api.authCode,
         data: {
           "email": email,
@@ -79,9 +79,9 @@ class Repository {
     String email,
     String pwd,
   ) async {
-    Response response;
+    Response? response;
     try {
-      response = await _dio.post(
+      response = await _dio!.post(
         "${Api.user}/",
         options: Options(
           headers: {
@@ -121,9 +121,9 @@ class Repository {
     String email,
     String pwd,
   ) async {
-    Response response;
+    Response? response;
     try {
-      response = await _dio.put(
+      response = await _dio!.put(
         "${Api.user}/",
         options: Options(
           headers: {
@@ -157,14 +157,14 @@ class Repository {
     return false;
   }
 
-  Future<Map> signIn(
+  Future<Map?> signIn(
     BuildContext context,
     String email,
     String pwd,
   ) async {
-    Response response;
+    Response? response;
     try {
-      response = await _dio.post(
+      response = await _dio!.post(
         Api.token,
         data: {
           "email": email,
@@ -176,7 +176,7 @@ class Repository {
     }
     switch (Status.of(response)) {
       case Status.OK:
-        return response.data;
+        return response!.data;
 
       case Status.RES_NOT_MATCH:
         await PopMenus.attention(
@@ -191,36 +191,36 @@ class Repository {
     return {};
   }
 
-  Future<Map> getUserInfo(int uid) async {
-    Response response;
+  Future<Map?> getUserInfo(int? uid) async {
+    Response? response;
     try {
-      response = await _dio.get("${Api.user}/$uid/userInfo");
+      response = await _dio!.get("${Api.user}/$uid/userInfo");
     } catch (e) {
       debugPrint(e.toString());
     }
     if (Status.of(response) == Status.OK) {
-      return response.data;
+      return response!.data;
     }
     return {};
   }
 
-  Future<int> getCoin(int uid) async {
-    Response response;
+  Future<int?> getCoin(int? uid) async {
+    Response? response;
     try {
-      response = await _dio.get("${Api.user}/$uid/coin");
+      response = await _dio!.get("${Api.user}/$uid/coin");
     } catch (e) {
       debugPrint(e.toString());
     }
     if (Status.of(response) == Status.OK) {
-      return response.data;
+      return response!.data;
     }
     return null;
   }
 
-  Future<List<int>> getPhoto(int uid) async {
-    Response response;
+  Future<List<int>?> getPhoto(int? uid) async {
+    Response? response;
     try {
-      response = await _dio.get(
+      response = await _dio!.get(
         "${Api.user}/$uid/userPhoto",
         options: Options(
           responseType: ResponseType.bytes,
@@ -230,16 +230,16 @@ class Repository {
       debugPrint(e.toString());
     }
     if (Status.of(response) == Status.OK) {
-      return response.data;
+      return response!.data;
     }
     return null;
   }
 
   Future<bool> uploadPhoto(
-      BuildContext context, String token, int uid, List<int> photo) async {
-    Response response;
+      BuildContext context, String? token, int? uid, List<int> photo) async {
+    Response? response;
     try {
-      response = await _dio.put("${Api.user}/$uid/userPhoto",
+      response = await _dio!.put("${Api.user}/$uid/userPhoto",
           options: Options(
             headers: {
               "token": token,
@@ -272,15 +272,15 @@ class Repository {
 
   Future<bool> modifyUserInfo(
     BuildContext context,
-    String token,
-    int uid,
-    String userName,
-    String gender,
-    String birthday,
+    String? token,
+    int? uid,
+    String? userName,
+    String? gender,
+    String? birthday,
   ) async {
-    Response response;
+    Response? response;
     try {
-      response = await _dio.put(
+      response = await _dio!.put(
         "${Api.user}/$uid/userInfo",
         options: Options(
           headers: {
@@ -315,11 +315,11 @@ class Repository {
     return false;
   }
 
-  Future<bool> getFollowState(
-      BuildContext context, String token, int uid, int followUid) async {
-    Response response;
+  Future<bool?> getFollowState(
+      BuildContext context, String? token, int? uid, int? followUid) async {
+    Response? response;
     try {
-      response = await _dio.get("${Api.community}/$uid/follow/$followUid",
+      response = await _dio!.get("${Api.community}/$uid/follow/$followUid",
           options: Options(
             headers: {
               "token": token,
@@ -330,7 +330,7 @@ class Repository {
     }
     switch (Status.of(response)) {
       case Status.OK:
-        return response.data;
+        return response!.data;
       case Status.INVALID_AUTHORIZE:
         await PopMenus.attention(
             context: context, content: Text(I18N.of("登录信息过期")));
@@ -345,11 +345,11 @@ class Repository {
     return false;
   }
 
-  Future<String> follow(
-      BuildContext context, String token, int uid, int followUid) async {
-    Response response;
+  Future<String?> follow(
+      BuildContext context, String? token, int? uid, int? followUid) async {
+    Response? response;
     try {
-      response = await _dio.post(
+      response = await _dio!.post(
         Api.follow,
         options: Options(
           headers: {
@@ -366,7 +366,7 @@ class Repository {
     }
     switch (Status.of(response)) {
       case Status.OK:
-        return response.data;
+        return response!.data;
       case Status.RES_NOT_ALLOW:
         await PopMenus.attention(
             context: context, content: Text(I18N.of("不能关注自己")));
@@ -385,11 +385,11 @@ class Repository {
     return null;
   }
 
-  Future<List> getFollowList(
-      BuildContext context, String token, int uid) async {
-    Response response;
+  Future<List?> getFollowList(
+      BuildContext context, String? token, int? uid) async {
+    Response? response;
     try {
-      response = await _dio.get(
+      response = await _dio!.get(
         Api.follow,
         options: Options(
           headers: {
@@ -405,7 +405,7 @@ class Repository {
     }
     switch (Status.of(response)) {
       case Status.OK:
-        return response.data;
+        return response!.data;
 
       case Status.INVALID_AUTHORIZE:
         await PopMenus.attention(
@@ -422,11 +422,11 @@ class Repository {
     return [];
   }
 
-  Future<List> getUserInfoLikeUserName(
+  Future<List?> getUserInfoLikeUserName(
       BuildContext context, String name) async {
-    Response response;
+    Response? response;
     try {
-      response = await _dio.get("${Api.user}/", queryParameters: {
+      response = await _dio!.get("${Api.user}/", queryParameters: {
         "name": name,
       });
     } catch (e) {
@@ -434,7 +434,7 @@ class Repository {
     }
     switch (Status.of(response)) {
       case Status.OK:
-        return response.data;
+        return response!.data;
       case Status.CONNECT_FAIL:
         await PopMenus.attention(
             context: context, content: Text(I18N.of("连接失败")));
@@ -443,10 +443,10 @@ class Repository {
     return [];
   }
 
-  Future<List> getCoinTop(BuildContext context, int topCount) async {
-    Response response;
+  Future<List?> getCoinTop(BuildContext context, int topCount) async {
+    Response? response;
     try {
-      response = await _dio.get("${Api.community}/coinTop", queryParameters: {
+      response = await _dio!.get("${Api.community}/coinTop", queryParameters: {
         "topCount": topCount,
       });
     } catch (e) {
@@ -454,7 +454,7 @@ class Repository {
     }
     switch (Status.of(response)) {
       case Status.OK:
-        return response.data;
+        return response!.data;
       case Status.CONNECT_FAIL:
         await PopMenus.attention(
             context: context, content: Text(I18N.of("连接失败")));
@@ -463,10 +463,10 @@ class Repository {
     return [];
   }
 
-  Future<List> getGoodsList(BuildContext context) async {
-    Response response;
+  Future<List?> getGoodsList(BuildContext context) async {
+    Response? response;
     try {
-      response = await _dio.get(
+      response = await _dio!.get(
         "${Api.shopping}/",
       );
     } catch (e) {
@@ -474,7 +474,7 @@ class Repository {
     }
     switch (Status.of(response)) {
       case Status.OK:
-        return response.data;
+        return response!.data;
       case Status.CONNECT_FAIL:
         await PopMenus.attention(
             context: context, content: Text(I18N.of("连接失败")));
@@ -483,10 +483,10 @@ class Repository {
     return [];
   }
 
-  Future<int> increaseCoin(BuildContext context, int uid, String token) async {
-    Response response;
+  Future<int?> increaseCoin(BuildContext context, int? uid, String? token) async {
+    Response? response;
     try {
-      response = await _dio.put(
+      response = await _dio!.put(
         "${Api.user}/$uid/coin",
         options: Options(headers: {
           "token": token,
@@ -497,7 +497,7 @@ class Repository {
     }
     switch (Status.of(response)) {
       case Status.OK:
-        return response.data;
+        return response!.data;
       case Status.INVALID_AUTHORIZE:
         await PopMenus.attention(
             context: context, content: Text(I18N.of("登录信息过期")));
@@ -518,10 +518,10 @@ class Repository {
   }
 
   Future<bool> buyGoods(
-      BuildContext context, String token, int uid, int goodsId) async {
-    Response response;
+      BuildContext context, String? token, int? uid, int? goodsId) async {
+    Response? response;
     try {
-      response = await _dio.post("${Api.shopping}/",
+      response = await _dio!.post("${Api.shopping}/",
           options: Options(headers: {
             "token": token,
           }),
@@ -562,10 +562,10 @@ class Repository {
   }
 
   Future<bool> uploadDB(
-      BuildContext context, int uid, String token, List<int> data) async {
-    Response response;
+      BuildContext context, int? uid, String? token, List<int> data) async {
+    Response? response;
     try {
-      response = await _dio.put(
+      response = await _dio!.put(
         "${Api.user}/$uid/data",
         options: Options(headers: {
           "token": token,
@@ -592,11 +592,11 @@ class Repository {
     return false;
   }
 
-  Future<List<int>> downloadDB(
-      BuildContext context, int uid, String token) async {
-    Response response;
+  Future<List<int>?> downloadDB(
+      BuildContext context, int? uid, String? token) async {
+    Response? response;
     try {
-      response = await _dio.get(
+      response = await _dio!.get(
         "${Api.user}/$uid/data",
         options: Options(
           responseType: ResponseType.bytes,
@@ -610,7 +610,7 @@ class Repository {
     }
     switch (Status.of(response)) {
       case Status.OK:
-        return response.data;
+        return response!.data;
       case Status.RES_NOT_FOUND:
         await PopMenus.attention(
             context: context, content: Text(I18N.of("云端无数据")));

+ 1 - 1
lib/network/Status.dart

@@ -10,7 +10,7 @@ class Status {
   static const String CONNECT_FAIL = "CONNECT_FAIL";
   static const String RES_NOT_ALLOW = "RES_NOT_ALLOW";
 
-  static String of(Response response) {
+  static String? of(Response? response) {
     if (response == null) {
       return CONNECT_FAIL;
     }

+ 3 - 3
lib/pages/home_page.dart

@@ -34,9 +34,9 @@ class HomePage extends StatelessWidget {
 class HomePageModel extends BaseModel {
   HomePageModel(BuildContext context) : super(context);
 
-  int currentIndex;
+  late int currentIndex;
 
-  PageController pageViewController;
+  PageController? pageViewController;
 
   @override
   void init(BuildContext context) {
@@ -53,7 +53,7 @@ class HomePageService extends BaseProvider {
   void changeNavigation(BuildContext context, int index) {
     HomePageModel model = Provider.of<HomePageModel>(context, listen: false);
     model.currentIndex = index;
-    model.pageViewController.animateToPage(index,
+    model.pageViewController!.animateToPage(index,
         duration: Duration(milliseconds: 300), curve: Curves.ease);
     model.refresh();
   }

+ 3 - 3
lib/pages/splash_page.dart

@@ -33,8 +33,8 @@ class SplashPage extends StatelessWidget {
 class SplashPageProvider extends BaseProvider {
   SplashPageProvider(BuildContext context) : super(context);
 
-  Timer timer;
-  bool isLoaded;
+  Timer? timer;
+  bool? isLoaded;
 
   Future<void> loadData(BuildContext context) async {
     // ================================== init ==================================
@@ -94,7 +94,7 @@ class SplashPageProvider extends BaseProvider {
   void dispose() {
     super.dispose();
     if (timer != null) {
-      timer.cancel();
+      timer!.cancel();
     }
   }
 }

+ 26 - 26
lib/provider/ConfigProvider.dart

@@ -3,23 +3,23 @@ import 'package:flutter_habit/common/LocalData.dart';
 import 'package:shared_preferences/shared_preferences.dart';
 
 class ConfigProvider extends ChangeNotifier {
-  int getUpTimeStart;
-  int getUpTimeEnd;
+  late int getUpTimeStart;
+  int? getUpTimeEnd;
 
-  int breakfastTimeStart;
-  int breakfastTimeEnd;
+  late int breakfastTimeStart;
+  int? breakfastTimeEnd;
 
-  int lunchTimeStart;
-  int lunchTimeEnd;
+  late int lunchTimeStart;
+  int? lunchTimeEnd;
 
-  int midRestTimeStart;
-  int midRestTimeEnd;
+  late int midRestTimeStart;
+  int? midRestTimeEnd;
 
-  int dinnerTimeStart;
-  int dinnerTimeEnd;
+  late int dinnerTimeStart;
+  int? dinnerTimeEnd;
 
-  int restTimeStart;
-  int restTimeEnd;
+  late int restTimeStart;
+  int? restTimeEnd;
 
   void init() {
     load();
@@ -27,27 +27,27 @@ class ConfigProvider extends ChangeNotifier {
 
     debugPrint("""init ConfigProvider to:
       getUpTimeStart = ${DateTime.fromMillisecondsSinceEpoch(getUpTimeStart).toString().substring(11, 16)}
-      getUpTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(getUpTimeEnd).toString().substring(11, 16)}
+      getUpTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(getUpTimeEnd!).toString().substring(11, 16)}
       
       breakfastTimeStart = ${DateTime.fromMillisecondsSinceEpoch(breakfastTimeStart).toString().substring(11, 16)}
-      breakfastTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(breakfastTimeEnd).toString().substring(11, 16)}
+      breakfastTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(breakfastTimeEnd!).toString().substring(11, 16)}
       
       midRestTimeStart = ${DateTime.fromMillisecondsSinceEpoch(midRestTimeStart).toString().substring(11, 16)}
-      midRestTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(midRestTimeEnd).toString().substring(11, 16)}
+      midRestTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(midRestTimeEnd!).toString().substring(11, 16)}
       
       lunchTimeStart = ${DateTime.fromMillisecondsSinceEpoch(lunchTimeStart).toString().substring(11, 16)}
-      lunchTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(lunchTimeEnd).toString().substring(11, 16)}
+      lunchTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(lunchTimeEnd!).toString().substring(11, 16)}
       
       dinnerTimeStart = ${DateTime.fromMillisecondsSinceEpoch(dinnerTimeStart).toString().substring(11, 16)}
-      dinnerTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(dinnerTimeEnd).toString().substring(11, 16)}
+      dinnerTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(dinnerTimeEnd!).toString().substring(11, 16)}
       
       restTimeStart = ${DateTime.fromMillisecondsSinceEpoch(restTimeStart).toString().substring(11, 16)}
-      restTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(restTimeEnd).toString().substring(11, 16)}
+      restTimeEnd = ${DateTime.fromMillisecondsSinceEpoch(restTimeEnd!).toString().substring(11, 16)}
       """);
   }
 
   void load() {
-    SharedPreferences sp = LocalData.getInstance();
+    SharedPreferences sp = LocalData.getInstance()!;
     getUpTimeStart = sp.getInt("getUpTimeStart") ?? DateTime(1,1,1,6).millisecondsSinceEpoch;
     getUpTimeEnd = sp.getInt("getUpTimeEnd") ?? DateTime(1,1,1,7).millisecondsSinceEpoch;
 
@@ -68,24 +68,24 @@ class ConfigProvider extends ChangeNotifier {
   }
 
   void store() {
-    SharedPreferences sp = LocalData.getInstance();
+    SharedPreferences sp = LocalData.getInstance()!;
     sp.setInt("getUpTimeStart", getUpTimeStart);
-    sp.setInt("getUpTimeEnd", getUpTimeEnd);
+    sp.setInt("getUpTimeEnd", getUpTimeEnd!);
 
     sp.setInt("breakfastTimeStart", breakfastTimeStart);
-    sp.setInt("breakfastTimeEnd", breakfastTimeEnd);
+    sp.setInt("breakfastTimeEnd", breakfastTimeEnd!);
 
     sp.setInt("lunchTimeStart", lunchTimeStart);
-    sp.setInt("lunchTimeEnd", lunchTimeEnd);
+    sp.setInt("lunchTimeEnd", lunchTimeEnd!);
 
     sp.setInt("midRestTimeStart", midRestTimeStart);
-    sp.setInt("midRestTimeEnd", midRestTimeEnd);
+    sp.setInt("midRestTimeEnd", midRestTimeEnd!);
 
     sp.setInt("dinnerTimeStart", dinnerTimeStart);
-    sp.setInt("dinnerTimeEnd", dinnerTimeEnd);
+    sp.setInt("dinnerTimeEnd", dinnerTimeEnd!);
 
     sp.setInt("restTimeStart", restTimeStart);
-    sp.setInt("restTimeEnd", restTimeEnd);
+    sp.setInt("restTimeEnd", restTimeEnd!);
   }
 
   void refresh() {

+ 68 - 68
lib/provider/DataProvider.dart

@@ -50,13 +50,13 @@ class DataProvider extends ChangeNotifier {
   }
 
   // basic info
-  double height;
-  double weight;
-  String bmi;
+  double? height;
+  double? weight;
+  String? bmi;
 
-  double breastLine;
-  double waistLine;
-  double hipLine;
+  double? breastLine;
+  double? waistLine;
+  double? hipLine;
 
   List<FlSpot> weightFlSpots = [];
   int weightChartSize = 7;
@@ -72,7 +72,7 @@ class DataProvider extends ChangeNotifier {
         .millisecondsSinceEpoch;
     // 基本信息
     List<BasicInfo> basicInfoList =
-        await BasicInfoMapper().selectWhere("date >= $dateTime90daysAgo");
+        (await BasicInfoMapper().selectWhere("date >= $dateTime90daysAgo"))!;
     height = null;
     weight = null;
     bmi = null;
@@ -83,7 +83,7 @@ class DataProvider extends ChangeNotifier {
     if (basicInfoList.isNotEmpty) {
       height = basicInfoList.last.getHeight();
       weight = basicInfoList.last.getWeight();
-      bmi = (weight / height / height * 10000).toStringAsFixed(2);
+      bmi = (weight! / height! / height! * 10000).toStringAsFixed(2);
       breastLine = basicInfoList.last.getBreastLine();
       waistLine = basicInfoList.last.getWaistLine();
       hipLine = basicInfoList.last.getHipLine();
@@ -99,33 +99,33 @@ class DataProvider extends ChangeNotifier {
       weightFlSpots.add(
         FlSpot(
           ConvertUtils.localDaysSinceEpoch(
-                  DateTime.fromMillisecondsSinceEpoch(i.getDate()))
+                  DateTime.fromMillisecondsSinceEpoch(i.getDate()!))
               .floorToDouble(),
-          i.getWeight(),
+          i.getWeight()!,
         ),
       );
       brestLineFlSpots.add(
         FlSpot(
           ConvertUtils.localDaysSinceEpoch(
-                  DateTime.fromMillisecondsSinceEpoch(i.getDate()))
+                  DateTime.fromMillisecondsSinceEpoch(i.getDate()!))
               .floorToDouble(),
-          i.getBreastLine(),
+          i.getBreastLine()!,
         ),
       );
       waistLineFlSpots.add(
         FlSpot(
           ConvertUtils.localDaysSinceEpoch(
-                  DateTime.fromMillisecondsSinceEpoch(i.getDate()))
+                  DateTime.fromMillisecondsSinceEpoch(i.getDate()!))
               .floorToDouble(),
-          i.getWaistLine(),
+          i.getWaistLine()!,
         ),
       );
       hipLineFlSpots.add(
         FlSpot(
           ConvertUtils.localDaysSinceEpoch(
-                  DateTime.fromMillisecondsSinceEpoch(i.getDate()))
+                  DateTime.fromMillisecondsSinceEpoch(i.getDate()!))
               .floorToDouble(),
-          i.getHipLine(),
+          i.getHipLine()!,
         ),
       );
     });
@@ -134,7 +134,7 @@ class DataProvider extends ChangeNotifier {
   }
 
   // life info
-  int lastNightSleepTime;
+  int? lastNightSleepTime;
   double todayInjectKCal = 0;
   int todayProgress = 0;
   double todayMoney = 0;
@@ -167,8 +167,8 @@ class DataProvider extends ChangeNotifier {
         .millisecondsSinceEpoch;
     // 日常生活
     List<LifeInfo> lifeInfoList =
-        await LifeInfoMapper().selectWhere("date >= $date91daysAgo");
-    List<FoodInfo> foodInfoList = await FoodInfoMapper().selectAll();
+        (await LifeInfoMapper().selectWhere("date >= $date91daysAgo"))!;
+    List<FoodInfo>? foodInfoList = await FoodInfoMapper().selectAll();
 
     // 构造点、数据
     sleepTimeFlSpots = [];
@@ -190,32 +190,32 @@ class DataProvider extends ChangeNotifier {
         LifeInfo lastLifeInfo = i == 0 ? LifeInfo() : lifeInfoList[i - 1];
         LifeInfo currLifeInfo = lifeInfoList[i];
         // 准备数据
-        int date = currLifeInfo.getDate();
-        int lastDate = lastLifeInfo.getDate();
-        int sleepTime;
+        int date = currLifeInfo.getDate()!;
+        int? lastDate = lastLifeInfo.getDate();
+        int? sleepTime;
         if (lastLifeInfo.getRestTime() != null &&
             currLifeInfo.getGetUpTime() != null) {
-          sleepTime = currLifeInfo.getGetUpTime() - lastLifeInfo.getRestTime();
+          sleepTime = currLifeInfo.getGetUpTime()! - lastLifeInfo.getRestTime()!;
         }
         lastNightSleepTime = sleepTime;
         double totalCal = 0;
         if (currLifeInfo.getBreakfastQuantity() != null) {
-          FoodInfo currBreakfastInfo = foodInfoList.firstWhere(
+          FoodInfo currBreakfastInfo = foodInfoList!.firstWhere(
               (test) => test.getId() == currLifeInfo.getBreakfastId());
-          totalCal += currBreakfastInfo.getHgkCalorie() *
-              currLifeInfo.getBreakfastQuantity();
+          totalCal += currBreakfastInfo.getHgkCalorie()! *
+              currLifeInfo.getBreakfastQuantity()!;
         }
         if (currLifeInfo.getLunchQuantity() != null) {
-          FoodInfo currLunchInfo = foodInfoList
+          FoodInfo currLunchInfo = foodInfoList!
               .firstWhere((test) => test.getId() == currLifeInfo.getLunchId());
           totalCal +=
-              currLunchInfo.getHgkCalorie() * currLifeInfo.getLunchQuantity();
+              currLunchInfo.getHgkCalorie()! * currLifeInfo.getLunchQuantity()!;
         }
         if (currLifeInfo.getDinnerQuantity() != null) {
-          FoodInfo currDinnerInfo = foodInfoList
+          FoodInfo currDinnerInfo = foodInfoList!
               .firstWhere((test) => test.getId() == currLifeInfo.getDinnerId());
           totalCal +=
-              currDinnerInfo.getHgkCalorie() * currLifeInfo.getDinnerQuantity();
+              currDinnerInfo.getHgkCalorie()! * currLifeInfo.getDinnerQuantity()!;
         }
         todayInjectKCal = totalCal;
         int progress = 0;
@@ -224,41 +224,41 @@ class DataProvider extends ChangeNotifier {
         progress += currLifeInfo.getGetUpTime() == null
             ? 0
             : VerifyUtils.isBetweenTime(configProvider.getUpTimeStart,
-                    currLifeInfo.getGetUpTime(), configProvider.getUpTimeEnd)
+                    currLifeInfo.getGetUpTime()!, configProvider.getUpTimeEnd)
                 ? 2
                 : 1;
         progress += currLifeInfo.getBreakfastTime() == null
             ? 0
             : VerifyUtils.isBetweenTime(
                     configProvider.breakfastTimeStart,
-                    currLifeInfo.getBreakfastTime(),
+                    currLifeInfo.getBreakfastTime()!,
                     configProvider.breakfastTimeEnd)
                 ? 2
                 : 1;
         progress += currLifeInfo.getLunchTime() == null
             ? 0
             : VerifyUtils.isBetweenTime(configProvider.lunchTimeStart,
-                    currLifeInfo.getLunchTime(), configProvider.lunchTimeEnd)
+                    currLifeInfo.getLunchTime()!, configProvider.lunchTimeEnd)
                 ? 2
                 : 1;
         progress += currLifeInfo.getMidRestTime() == null
             ? 0
             : VerifyUtils.isBetweenTime(
                     configProvider.midRestTimeStart,
-                    currLifeInfo.getMidRestTime(),
+                    currLifeInfo.getMidRestTime()!,
                     configProvider.midRestTimeEnd)
                 ? 2
                 : 1;
         progress += currLifeInfo.getDinnerTime() == null
             ? 0
             : VerifyUtils.isBetweenTime(configProvider.dinnerTimeStart,
-                    currLifeInfo.getDinnerTime(), configProvider.dinnerTimeEnd)
+                    currLifeInfo.getDinnerTime()!, configProvider.dinnerTimeEnd)
                 ? 2
                 : 1;
         progress += currLifeInfo.getRestTime() == null
             ? 0
             : VerifyUtils.isBetweenTime(configProvider.restTimeStart,
-                    currLifeInfo.getRestTime(), configProvider.restTimeEnd)
+                    currLifeInfo.getRestTime()!, configProvider.restTimeEnd)
                 ? 2
                 : 1;
         todayProgress = progress;
@@ -269,7 +269,7 @@ class DataProvider extends ChangeNotifier {
                       DateTime.fromMillisecondsSinceEpoch(lastDate))
                   .floorToDouble(),
               ConvertUtils.fixedDouble(
-                  ConvertUtils.hourFormMilliseconds(lastNightSleepTime), 2)));
+                  ConvertUtils.hourFormMilliseconds(lastNightSleepTime!), 2)));
         }
         injectKCalFlSpots.add(FlSpot(
             ConvertUtils.localDaysSinceEpoch(
@@ -290,7 +290,7 @@ class DataProvider extends ChangeNotifier {
                   .floorToDouble(),
               24 -
                   ConvertUtils.hourFormMillisecondsSinceEpoch(
-                      currLifeInfo.getGetUpTime())));
+                      currLifeInfo.getGetUpTime()!)));
         }
         if (currLifeInfo.getMidRestTime() != null) {
           midRestTimeFlSpots.add(FlSpot(
@@ -299,7 +299,7 @@ class DataProvider extends ChangeNotifier {
                   .floorToDouble(),
               24 -
                   ConvertUtils.hourFormMillisecondsSinceEpoch(
-                      currLifeInfo.getMidRestTime())));
+                      currLifeInfo.getMidRestTime()!)));
         }
         if (currLifeInfo.getRestTime() != null) {
           restTimeFlSpots.add(FlSpot(
@@ -308,7 +308,7 @@ class DataProvider extends ChangeNotifier {
                   .floorToDouble(),
               24 -
                   ConvertUtils.hourFormMillisecondsSinceEpoch(
-                      currLifeInfo.getRestTime())));
+                      currLifeInfo.getRestTime()!)));
         }
 
         if (currLifeInfo.getBreakfastTime() != null) {
@@ -318,7 +318,7 @@ class DataProvider extends ChangeNotifier {
                   .floorToDouble(),
               24 -
                   ConvertUtils.hourFormMillisecondsSinceEpoch(
-                      currLifeInfo.getBreakfastTime())));
+                      currLifeInfo.getBreakfastTime()!)));
         }
         if (currLifeInfo.getLunchTime() != null) {
           eatLunchTimeFlSpots.add(FlSpot(
@@ -327,7 +327,7 @@ class DataProvider extends ChangeNotifier {
                   .floorToDouble(),
               24 -
                   ConvertUtils.hourFormMillisecondsSinceEpoch(
-                      currLifeInfo.getLunchTime())));
+                      currLifeInfo.getLunchTime()!)));
         }
         if (currLifeInfo.getDinnerTime() != null) {
           eatDinnerTimeFlSpots.add(FlSpot(
@@ -336,7 +336,7 @@ class DataProvider extends ChangeNotifier {
                   .floorToDouble(),
               24 -
                   ConvertUtils.hourFormMillisecondsSinceEpoch(
-                      currLifeInfo.getDinnerTime())));
+                      currLifeInfo.getDinnerTime()!)));
         }
 
         double totalMoney = 0;
@@ -371,44 +371,44 @@ class DataProvider extends ChangeNotifier {
     int date7daysAgo = ConvertUtils.dateOfDateTime(DateTime.now())
         .subtract(Duration(days: 7))
         .millisecondsSinceEpoch;
-    List<ExerciseInfo> exerciseInfoList = await ExerciseInfoMapper()
-        .selectWhere("exerciseTime >= $date90daysAgo");
+    List<ExerciseInfo> exerciseInfoList = (await ExerciseInfoMapper()
+        .selectWhere("exerciseTime >= $date90daysAgo"))!;
     List<ExerciseInfo> sevenDayExerciseInfoList =
-        await ExerciseInfoMapper().selectWhere("exerciseTime >= $date7daysAgo");
+        (await ExerciseInfoMapper().selectWhere("exerciseTime >= $date7daysAgo"))!;
     List<ScheduledExercise> schedules =
-        await ScheduledExerciseMapper().selectAll();
-    List<SportInfo> sports = await SportInfoMapper().selectAll();
+        (await ScheduledExerciseMapper().selectAll())!;
+    List<SportInfo>? sports = await SportInfoMapper().selectAll();
     scheduledExerciseSportInfoList = schedules.map((i) {
       return MapEntry(
-          i, sports.firstWhere((test) => test.getId() == i.getSportId()));
+          i, sports!.firstWhere((test) => test.getId() == i.getSportId()));
     }).toList();
     // 卡
     scheduledExerciseCount = schedules.length;
     sevenDayExerciseTimes = sevenDayExerciseInfoList.length;
     sevenDayExerciseTotalKCal = 0;
     sevenDayExerciseInfoList.forEach((i) {
-      sevenDayExerciseTotalKCal += i.getExerciseQuantity() *
-          sports
+      sevenDayExerciseTotalKCal += i.getExerciseQuantity()! *
+          sports!
               .firstWhere((test) => test.getId() == i.getSportId())
-              .getHkCalorie();
+              .getHkCalorie()!;
     });
     // 表
     exerciseInfoFlSpots = [];
     Map<int, double> temp = {};
     exerciseInfoList.forEach((i) {
       int currDay = ConvertUtils.localDaysSinceEpoch(
-              DateTime.fromMillisecondsSinceEpoch(i.getExerciseTime()))
+              DateTime.fromMillisecondsSinceEpoch(i.getExerciseTime()!))
           .floor();
       if (temp[currDay] == null) {
-        temp[currDay] = i.getExerciseQuantity() *
-            sports
+        temp[currDay] = i.getExerciseQuantity()! *
+            sports!
                 .firstWhere((test) => test.getId() == i.getSportId())
-                .getHkCalorie();
+                .getHkCalorie()!;
       } else {
-        temp[currDay] += i.getExerciseQuantity() *
-            sports
+        temp[currDay] += i.getExerciseQuantity()! *
+            sports!
                 .firstWhere((test) => test.getId() == i.getSportId())
-                .getHkCalorie();
+                .getHkCalorie()!;
       }
     });
     temp.forEach((k, v) {
@@ -432,13 +432,13 @@ class DataProvider extends ChangeNotifier {
         .subtract(Duration(days: 90))
         .millisecondsSinceEpoch;
     List<StudyInfo> studyInfoList =
-        await StudyInfoMapper().selectWhere("date >= $date90daysAgo");
+        (await StudyInfoMapper().selectWhere("date >= $date90daysAgo"))!;
     List<StudyInfo> lateList =
-        await StudyInfoMapper().selectWhere("isLate = 1");
+        (await StudyInfoMapper().selectWhere("isLate = 1"))!;
     List<StudyInfo> absentList =
-        await StudyInfoMapper().selectWhere("isAbsent = 1");
-    List<StudyInfo> unSolveTroublesAndUnDoneHomeList = await StudyInfoMapper()
-        .selectWhere("isTroublesSolved = 0 or isHomeWorkDone == 0");
+        (await StudyInfoMapper().selectWhere("isAbsent = 1"))!;
+    List<StudyInfo> unSolveTroublesAndUnDoneHomeList = (await StudyInfoMapper()
+        .selectWhere("isTroublesSolved = 0 or isHomeWorkDone == 0"))!;
     lateTimes = 0;
     absentTimes = 0;
     unSolveTroubles = 0;
@@ -463,7 +463,7 @@ class DataProvider extends ChangeNotifier {
     Map<int, int> temp = {};
     studyInfoList.forEach((i) {
       int currDay = ConvertUtils.localDaysSinceEpoch(
-              DateTime.fromMillisecondsSinceEpoch(i.getDate()))
+              DateTime.fromMillisecondsSinceEpoch(i.getDate()!))
           .floor();
       if (temp[currDay] == null) {
         temp[currDay] = 1;
@@ -486,17 +486,17 @@ class DataProvider extends ChangeNotifier {
     int todayZeroTime =
         ConvertUtils.dateOfDateTime(DateTime.now()).millisecondsSinceEpoch;
     List<BasicInfo> l1 =
-        await BasicInfoMapper().selectWhere("date >= $todayZeroTime");
+        (await BasicInfoMapper().selectWhere("date >= $todayZeroTime"))!;
     if (l1.isNotEmpty) {
       todayEvaluate++;
     }
     List<ExerciseInfo> l2 =
-    await ExerciseInfoMapper().selectWhere("exerciseTime >= $todayZeroTime");
+    (await ExerciseInfoMapper().selectWhere("exerciseTime >= $todayZeroTime"))!;
     if (l2.isNotEmpty) {
       todayEvaluate++;
     }
     List<StudyInfo> l3 =
-    await StudyInfoMapper().selectWhere("date >= $todayZeroTime");
+    (await StudyInfoMapper().selectWhere("date >= $todayZeroTime"))!;
     if (l3.isNotEmpty) {
       todayEvaluate++;
     }

+ 15 - 15
lib/provider/NotificationProvider.dart

@@ -6,14 +6,14 @@ import 'package:flutter_habit/provider/ConfigProvider.dart';
 import 'package:shared_preferences/shared_preferences.dart';
 
 class NotificationProvider extends ChangeNotifier {
-  FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
+  FlutterLocalNotificationsPlugin? flutterLocalNotificationsPlugin;
 
-  bool getUpNotification;
-  bool breakfastNotification;
-  bool lunchNotification;
-  bool midRestNotification;
-  bool dinnerNotification;
-  bool restNotification;
+  late bool getUpNotification;
+  late bool breakfastNotification;
+  late bool lunchNotification;
+  late bool midRestNotification;
+  late bool dinnerNotification;
+  late bool restNotification;
 
   Future<void> init() async {
     await initFlutterLocalNotificationsPlugin();
@@ -33,7 +33,7 @@ class NotificationProvider extends ChangeNotifier {
       InitializationSettings initializationSettings = InitializationSettings(
           android: initializationSettingsAndroid,
           iOS: initializationSettingsIOS);
-      flutterLocalNotificationsPlugin.initialize(initializationSettings);
+      flutterLocalNotificationsPlugin!.initialize(initializationSettings);
       debugPrint("init NotificationsUtils");
     }
   }
@@ -50,8 +50,8 @@ class NotificationProvider extends ChangeNotifier {
 
   Future<List<PendingNotificationRequest>> getNotifications() async {
     List pendingNotificationRequests =
-        await flutterLocalNotificationsPlugin.pendingNotificationRequests();
-    return pendingNotificationRequests;
+        await flutterLocalNotificationsPlugin!.pendingNotificationRequests();
+    return pendingNotificationRequests as FutureOr<List<PendingNotificationRequest>>;
   }
 
   Future<void> startScheduledTasks() async {
@@ -146,7 +146,7 @@ class NotificationProvider extends ChangeNotifier {
         android: androidPlatformChannelSpecifics,
         iOS: iOSPlatformChannelSpecifics);
 
-    await flutterLocalNotificationsPlugin.show(
+    await flutterLocalNotificationsPlugin!.show(
         id, title, body, platformChannelSpecifics);
     debugPrint("scheduledNotice $hour $minute $second");
   }
@@ -164,16 +164,16 @@ class NotificationProvider extends ChangeNotifier {
         android: androidPlatformChannelSpecifics,
         iOS: iOSPlatformChannelSpecifics);
 
-    await flutterLocalNotificationsPlugin.show(
+    await flutterLocalNotificationsPlugin!.show(
         id, title, body, platformChannelSpecifics);
   }
 
   Future<void> cancel(int id) async {
-    await flutterLocalNotificationsPlugin.cancel(id);
+    await flutterLocalNotificationsPlugin!.cancel(id);
   }
 
   void load() {
-    SharedPreferences sp = LocalData.getInstance();
+    SharedPreferences sp = LocalData.getInstance()!;
     getUpNotification = sp.getBool("getUpNotification") ?? true;
     breakfastNotification = sp.getBool("breakfastNotification") ?? true;
     lunchNotification = sp.getBool("lunchNotification") ?? true;
@@ -183,7 +183,7 @@ class NotificationProvider extends ChangeNotifier {
   }
 
   void store() {
-    SharedPreferences sp = LocalData.getInstance();
+    SharedPreferences sp = LocalData.getInstance()!;
     sp.setBool("getUpNotification", getUpNotification);
     sp.setBool("breakfastNotification", breakfastNotification);
     sp.setBool("lunchNotification", lunchNotification);

+ 7 - 7
lib/provider/ThemeProvider.dart

@@ -3,13 +3,13 @@ import 'package:flutter/material.dart';
 import '../common/LocalData.dart';
 
 class ThemeProvider extends ChangeNotifier {
-  int currentIndex;
+  int? currentIndex;
 
-  MaterialColor currentMaterialColor;
+  MaterialColor? currentMaterialColor;
 
-  Brightness currentBrightness;
+  Brightness? currentBrightness;
 
-  List<Color> otherColors;
+  late List<Color> otherColors;
 
   ThemeProvider() {
     currentIndex = 0;
@@ -19,10 +19,10 @@ class ThemeProvider extends ChangeNotifier {
   }
 
   void init() {
-    int index = LocalData.getInstance().getInt("theme");
+    int? index = LocalData.getInstance()!.getInt("theme");
     if (index == null) {
       index = 0;
-      LocalData.getInstance().setInt("theme", index);
+      LocalData.getInstance()!.setInt("theme", index);
     }
     changeTheme(index);
     debugPrint(
@@ -38,7 +38,7 @@ class ThemeProvider extends ChangeNotifier {
       currentBrightness = Brightness.light;
     }
     currentIndex = index;
-    LocalData.getInstance().setInt("theme", index);
+    LocalData.getInstance()!.setInt("theme", index);
     otherColors = List<Color>.of(themeColors);
     otherColors.remove(currentMaterialColor);
     notifyListeners();

+ 25 - 25
lib/provider/UserProvider.dart

@@ -6,15 +6,15 @@ import 'package:flutter_habit/common/LocalData.dart';
 import 'package:flutter_habit/pages/home_page.dart';
 
 class UserProvider extends ChangeNotifier {
-  String token;
+  String? token;
 
-  int uid;
-  String email;
-  String userName;
-  String gender;
-  String birthday;
-  Uint8List photo;
-  int coins;
+  int? uid;
+  String? email;
+  String? userName;
+  String? gender;
+  String? birthday;
+  Uint8List? photo;
+  int? coins;
 
   void init() {
     load();
@@ -30,31 +30,31 @@ class UserProvider extends ChangeNotifier {
   }
 
   void store() {
-    LocalData.getInstance().setString("token", token);
-    LocalData.getInstance().setInt("uid", uid);
-    LocalData.getInstance().setString("email", email);
-    LocalData.getInstance().setString("userName", userName);
-    LocalData.getInstance().setString("gender", gender);
-    LocalData.getInstance().setString("birthday", birthday);
-    LocalData.getInstance().setString(
-        "photo", photo == null ? null : Base64Encoder().convert(photo));
-    LocalData.getInstance().setInt("coins", coins);
+    LocalData.getInstance()!.setString("token", token!);
+    LocalData.getInstance()!.setInt("uid", uid!);
+    LocalData.getInstance()!.setString("email", email!);
+    LocalData.getInstance()!.setString("userName", userName!);
+    LocalData.getInstance()!.setString("gender", gender!);
+    LocalData.getInstance()!.setString("birthday", birthday!);
+    LocalData.getInstance()!.setString(
+        "photo", photo == null ? null : Base64Encoder().convert(photo!));
+    LocalData.getInstance()!.setInt("coins", coins!);
   }
 
   void load() {
-    token = LocalData.getInstance().getString("token");
-    uid = LocalData.getInstance().getInt("uid");
-    email = LocalData.getInstance().getString("email");
-    userName = LocalData.getInstance().getString("userName");
-    gender = LocalData.getInstance().getString("gender");
-    birthday = LocalData.getInstance().getString("birthday");
-    String listString = LocalData.getInstance().getString("photo");
+    token = LocalData.getInstance()!.getString("token");
+    uid = LocalData.getInstance()!.getInt("uid");
+    email = LocalData.getInstance()!.getString("email");
+    userName = LocalData.getInstance()!.getString("userName");
+    gender = LocalData.getInstance()!.getString("gender");
+    birthday = LocalData.getInstance()!.getString("birthday");
+    String? listString = LocalData.getInstance()!.getString("photo");
     if (listString == null) {
       photo = null;
     } else {
       photo = Base64Decoder().convert(listString);
     }
-    coins = LocalData.getInstance().getInt("coins");
+    coins = LocalData.getInstance()!.getInt("coins");
   }
 
   Future<void> cleanDataAndBackToHome(BuildContext context) async {

+ 2 - 2
lib/view/context/BasicInfoContext.dart

@@ -83,7 +83,7 @@ class _BasicInfoContextView extends StatelessWidget {
       title: Text(
         userProvider.userName ?? "Habit",
         maxLines: 1,
-        style: Theme.of(context).textTheme.titleLarge.copyWith(fontSize: 35),
+        style: Theme.of(context).textTheme.titleLarge!.copyWith(fontSize: 35),
       ),
       subtitle: Text(I18N.of("基本信息")),
       child: Row(
@@ -100,7 +100,7 @@ class _BasicInfoContextView extends StatelessWidget {
                   child: ClipRRect(
                     borderRadius: BorderRadius.circular(10),
                     child: Image.memory(
-                      userProvider.photo,
+                      userProvider.photo!,
                       width: 130,
                       height: 130,
                     ),

+ 6 - 6
lib/view/context/ExerciseInfoContext.dart

@@ -43,7 +43,7 @@ class ExerciseInfoContextService extends BaseProvider {
         await ScheduledExerciseMapper().delete(mapEntry.key);
         SportInfo sportInfo = SportInfo();
         sportInfo.setId(mapEntry.value.getId());
-        sportInfo.setSportTimes(mapEntry.value.getSportTimes() - 1);
+        sportInfo.setSportTimes(mapEntry.value.getSportTimes()! - 1);
         await SportInfoMapper().updateByFirstKeySelective(sportInfo);
         await Provider.of<DataProvider>(context, listen: false)
             .loadExerciseInfoData();
@@ -63,15 +63,15 @@ class ExerciseInfoContextService extends BaseProvider {
         exerciseInfo.setExerciseQuantity(mapEntry.key.getQuantity());
         exerciseInfo.setExerciseTime(now.millisecondsSinceEpoch);
         // 今日首次运动?
-        List<ExerciseInfo> localExerciseInfo = await ExerciseInfoMapper().selectWhere(
-            "exerciseTime > ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}");
+        List<ExerciseInfo> localExerciseInfo = (await ExerciseInfoMapper().selectWhere(
+            "exerciseTime > ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}"))!;
         if (localExerciseInfo.isEmpty){
           // 今日首次运动
           // 增加金币
           UserProvider userProvider =
           Provider.of<UserProvider>(context, listen: false);
           if (userProvider.token != null) {
-            int increasedCoin = await Repository.getInstance()
+            int? increasedCoin = await Repository.getInstance()!
                 .increaseCoin(context, userProvider.uid, userProvider.token);
             if (increasedCoin != null) {
               await PopMenus.coinAdd(
@@ -234,10 +234,10 @@ class _ExerciseInfoContextView extends StatelessWidget {
                 children: <Widget>[
                   Text("${I18N.of("运动类型")}: ${i.value.getName()}"),
                   Text(
-                      "${I18N.of("运动时长")}: ${ConvertUtils.fixedDouble(i.key.getQuantity() * 60, 2)} min"),
+                      "${I18N.of("运动时长")}: ${ConvertUtils.fixedDouble(i.key.getQuantity()! * 60, 2)} min"),
                   Text("${I18N.of("消耗")}: ${i.value.getHkCalorie()} h/kcal"),
                   Text(
-                      "${I18N.of("预计消耗")}: ${ConvertUtils.fixedDouble(i.key.getQuantity() * i.value.getHkCalorie(), 2)} kcal"),
+                      "${I18N.of("预计消耗")}: ${ConvertUtils.fixedDouble(i.key.getQuantity()! * i.value.getHkCalorie()!, 2)} kcal"),
                   Row(
                     mainAxisAlignment: MainAxisAlignment.end,
                     children: <Widget>[

+ 1 - 1
lib/view/context/LifeInfoContext.dart

@@ -168,7 +168,7 @@ class _LifeInfoContextView extends StatelessWidget {
             crossAxisAlignment: CrossAxisAlignment.start,
             children: <Widget>[
               Text(
-                "${I18N.of("昨夜睡眠时长")}: ${dataProvider.lastNightSleepTime == null ? I18N.of("无数据") : ConvertUtils.fixedDouble(ConvertUtils.hourFormMilliseconds(dataProvider.lastNightSleepTime), 2)} h",
+                "${I18N.of("昨夜睡眠时长")}: ${dataProvider.lastNightSleepTime == null ? I18N.of("无数据") : ConvertUtils.fixedDouble(ConvertUtils.hourFormMilliseconds(dataProvider.lastNightSleepTime!), 2)} h",
               ),
               Text(
                 "${I18N.of("摄入卡路里总量")}: ${dataProvider.todayInjectKCal.toStringAsFixed(2)} kcal",

+ 2 - 2
lib/view/context/StudyInfoContext.dart

@@ -138,10 +138,10 @@ class _StudyInfoContextView extends StatelessWidget {
       children: dataProvider.unSolveStudyInfoList.map((i) {
         return BaseCard(
           title: Text(
-            i.getCourseName(),
+            i.getCourseName()!,
             style: Theme.of(context).textTheme.titleLarge,
           ),
-          subtitle: Text(DateTime.fromMillisecondsSinceEpoch(i.getDate())
+          subtitle: Text(DateTime.fromMillisecondsSinceEpoch(i.getDate()!)
               .toString()
               .substring(0, 16)),
           child: Row(

+ 3 - 3
lib/view/context/widget/BaseCard.dart

@@ -1,9 +1,9 @@
 import 'package:flutter/material.dart';
 
 class BaseCard extends StatelessWidget {
-  final Widget title;
-  final Widget subtitle;
-  final Widget child;
+  final Widget? title;
+  final Widget? subtitle;
+  final Widget? child;
 
   BaseCard({this.title, this.subtitle, this.child});
 

+ 7 - 7
lib/view/context/widget/DateTimeMultiLineChart.dart

@@ -8,10 +8,10 @@ import 'package:provider/provider.dart';
 class DateTimeMultiLineChart extends StatelessWidget {
   final Map<String, List<FlSpot>> lineNameSportsMap;
 
-  final int size;
+  final int? size;
 
   DateTimeMultiLineChart({
-    @required this.lineNameSportsMap,
+    required this.lineNameSportsMap,
     this.size,
   });
 
@@ -21,7 +21,7 @@ class DateTimeMultiLineChart extends StatelessWidget {
       LineChartBarData lineChartBarData = LineChartBarData(
         spots: sports,
         // 圆滑
-        isCurved: size > 7,
+        isCurved: size! > 7,
         // 线条颜色
         color: 
           Provider.of<ThemeProvider>(context, listen: false).otherColors[i]
@@ -32,7 +32,7 @@ class DateTimeMultiLineChart extends StatelessWidget {
         isStrokeCapRound: true,
         // 点配置
         dotData: FlDotData(
-          show: size < 30,
+          show: size! < 30,
           // getDotColor: (spot, percent, barData) =>
           //     Provider.of<ThemeProvider>(context, listen: false).otherColors[i],
           // dotSize: 3,
@@ -52,7 +52,7 @@ class DateTimeMultiLineChart extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
-    double maxY, minY, maxX, minX, xInterval, yInterval;
+    double? maxY, minY, maxX, minX, xInterval, yInterval;
     bool isEmpty = false;
     lineNameSportsMap.values.forEach((i) {
       if (i.isEmpty) {
@@ -63,7 +63,7 @@ class DateTimeMultiLineChart extends StatelessWidget {
       double now =
           ConvertUtils.localDaysSinceEpoch(DateTime.now()).floorToDouble();
       maxX = now;
-      minX = now - size;
+      minX = now - size!;
       maxY = 24;
       minY = 0;
       switch (size) {
@@ -91,7 +91,7 @@ class DateTimeMultiLineChart extends StatelessWidget {
                 I18N.of("无数据"),
                 style: Theme.of(context)
                     .textTheme
-                    .displaySmall
+                    .displaySmall!
                     .copyWith(color: Theme.of(context).colorScheme.secondary),
               ),
               Divider(),

+ 15 - 15
lib/view/context/widget/DateValueMultiLineChart.dart

@@ -8,10 +8,10 @@ import 'package:provider/provider.dart';
 class DateValueMultiLineChart extends StatelessWidget {
   final Map<String, List<FlSpot>> lineNameSportsMap;
 
-  final int size;
+  final int? size;
 
   DateValueMultiLineChart({
-    @required this.lineNameSportsMap,
+    required this.lineNameSportsMap,
     this.size,
   });
 
@@ -21,7 +21,7 @@ class DateValueMultiLineChart extends StatelessWidget {
       LineChartBarData lineChartBarData = LineChartBarData(
         spots: sports,
         // 圆滑
-        isCurved: size > 7,
+        isCurved: size! > 7,
         // 线条颜色
         color: 
           Provider.of<ThemeProvider>(context, listen: false).otherColors[i]
@@ -32,7 +32,7 @@ class DateValueMultiLineChart extends StatelessWidget {
         isStrokeCapRound: true,
         // 点配置
         dotData: FlDotData(
-          show: size < 30,
+          show: size! < 30,
           // getDotColor: (spot, percent, barData) =>
           //     Provider.of<ThemeProvider>(context, listen: false).otherColors[i],
           // dotSize: 3,
@@ -52,31 +52,31 @@ class DateValueMultiLineChart extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
-    double maxY, minY, maxX, minX, xInterval, yInterval;
+    double? maxY, minY, maxX, minX, xInterval, yInterval;
     if (lineNameSportsMap.values.first.isNotEmpty) {
       double now =
           ConvertUtils.localDaysSinceEpoch(DateTime.now()).floorToDouble();
       maxX = now;
-      minX = now - size;
+      minX = now - size!;
       maxY = lineNameSportsMap.values.first.first.y;
       minY = lineNameSportsMap.values.first.first.y;
       lineNameSportsMap.values.forEach((sports) {
         sports.forEach((i) {
-          if (i.y < minY) {
+          if (i.y < minY!) {
             minY = i.y;
           }
-          if (i.y > maxY) {
+          if (i.y > maxY!) {
             maxY = i.y;
           }
         });
       });
       if (maxY == maxY) {
-        maxY = maxY + 10;
-        minY = minY - 10;
+        maxY = maxY! + 10;
+        minY = minY! - 10;
       } else {
-        double height = maxY - minY;
-        maxY = maxY + height;
-        minY = minY - height;
+        double height = maxY! - minY!;
+        maxY = maxY! + height;
+        minY = minY! - height;
       }
       switch (size) {
         case 7:
@@ -92,7 +92,7 @@ class DateValueMultiLineChart extends StatelessWidget {
           xInterval = 1;
           break;
       }
-      yInterval = ((maxY - minY) / 6);
+      yInterval = ((maxY! - minY!) / 6);
     }
     int i = 0;
     return lineNameSportsMap.values.first.isEmpty
@@ -103,7 +103,7 @@ class DateValueMultiLineChart extends StatelessWidget {
                 I18N.of("无数据"),
                 style: Theme.of(context)
                     .textTheme
-                    .displaySmall
+                    .displaySmall!
                     .copyWith(color: Theme.of(context).colorScheme.secondary),
               ),
               Divider(),

+ 17 - 17
lib/view/context/widget/DateValueSingleLineChart.dart

@@ -6,45 +6,45 @@ import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 class DateValueSingleLineChart extends StatelessWidget {
   final List<FlSpot> sports;
 
-  final int size;
+  final int? size;
 
   final bool isEndYesterday;
 
   DateValueSingleLineChart({
-    @required this.sports,
+    required this.sports,
     this.size,
     this.isEndYesterday = false,
   });
 
   @override
   Widget build(BuildContext context) {
-    double maxY, minY, maxX, minX, xInterval, yInterval;
+    double? maxY, minY, maxX, minX, xInterval, yInterval;
     if (sports.isNotEmpty) {
       double now = ConvertUtils.localDaysSinceEpoch(isEndYesterday
               ? DateTime.now().subtract(Duration(days: 1))
               : DateTime.now())
           .floorToDouble();
       maxX = now;
-      minX = now - size;
+      minX = now - size!;
       maxY = sports[0].y;
       minY = sports[0].y;
       sports.forEach((i) {
-        if (i.y < minY) {
+        if (i.y < minY!) {
           minY = i.y;
         }
-        if (i.y > maxY) {
+        if (i.y > maxY!) {
           maxY = i.y;
         }
       });
       if (maxY == minY) {
-        maxY = maxY + 10;
-        minY = minY - 10;
+        maxY = maxY! + 10;
+        minY = minY! - 10;
       } else {
-        double height = maxY - minY;
-        maxY = maxY + height;
-        minY = minY - height;
-        if (minY < 0) {
-          maxY = maxY + minY;
+        double height = maxY! - minY!;
+        maxY = maxY! + height;
+        minY = minY! - height;
+        if (minY! < 0) {
+          maxY = maxY! + minY!;
           minY = 0;
         }
       }
@@ -62,7 +62,7 @@ class DateValueSingleLineChart extends StatelessWidget {
           xInterval = 1;
           break;
       }
-      yInterval = ((maxY - minY) / 6);
+      yInterval = ((maxY! - minY!) / 6);
     }
     return sports.isEmpty
         ? Container(
@@ -72,7 +72,7 @@ class DateValueSingleLineChart extends StatelessWidget {
                 I18N.of("无数据"),
                 style: Theme.of(context)
                     .textTheme
-                    .displaySmall
+                    .displaySmall!
                     .copyWith(color: Theme.of(context).colorScheme.secondary),
               ),
               Divider(),
@@ -184,7 +184,7 @@ class DateValueSingleLineChart extends StatelessWidget {
                       LineChartBarData(
                         spots: sports,
                         // 圆滑
-                        isCurved: size > 7,
+                        isCurved: size! > 7,
                         // 线条颜色
                         color: Theme.of(context).colorScheme.secondary,
                         // 线条宽度
@@ -193,7 +193,7 @@ class DateValueSingleLineChart extends StatelessWidget {
                         isStrokeCapRound: true,
                         // 点配置
                         dotData: FlDotData(
-                          show: size < 30,
+                          show: size! < 30,
                           // getDotColor: (spot, percent, barData) =>
                           //     Theme.of(context).colorScheme.secondary,
                           // dotSize: 3,

+ 2 - 2
lib/view/context/widget/StudyInfoDetailsPage.dart

@@ -21,7 +21,7 @@ class StudyInfoDetailsPage extends StatelessWidget {
         child: ListView(
           children: <Widget>[
             Text(
-              studyInfo.getCourseName(),
+              studyInfo.getCourseName()!,
               style: Theme.of(context).textTheme.titleLarge,
             ),
             Divider(),
@@ -177,7 +177,7 @@ class StudyInfoDetailsPage extends StatelessWidget {
             Divider(),
             Center(
               child: Text(
-                DateTime.fromMillisecondsSinceEpoch(studyInfo.getDate())
+                DateTime.fromMillisecondsSinceEpoch(studyInfo.getDate()!)
                     .toString()
                     .substring(0, 16),
                 style: Theme.of(context).textTheme.bodySmall,

+ 5 - 5
lib/view/drawer/HomePageDrawer.dart

@@ -35,7 +35,7 @@ class HomePageDrawer extends StatelessWidget {
                       children: <Widget>[
                         Text(
                           I18N.of("欢迎"),
-                          style: Theme.of(context).textTheme.displayLarge.copyWith(
+                          style: Theme.of(context).textTheme.displayLarge!.copyWith(
                               color: Theme.of(context).colorScheme.onPrimary),
                         ),
                         Text(
@@ -47,7 +47,7 @@ class HomePageDrawer extends StatelessWidget {
                           "Habit",
                           style: Theme.of(context)
                               .textTheme
-                              .titleLarge
+                              .titleLarge!
                               .copyWith(
                               color: Theme.of(context).colorScheme.onPrimary),
                         ),
@@ -64,7 +64,7 @@ class HomePageDrawer extends StatelessWidget {
                               )
                             : ClipOval(
                                 child: Image.memory(
-                                  userProvider.photo,
+                                  userProvider.photo!,
                                   width: 70,
                                   height: 70,
                                 ),
@@ -73,7 +73,7 @@ class HomePageDrawer extends StatelessWidget {
                         Text(
                           userProvider.userName != null &&
                                   userProvider.userName != null
-                              ? userProvider.userName
+                              ? userProvider.userName!
                               : I18N.of("未登录"),
                           style: TextStyle(
                               color: Theme.of(context).colorScheme.onPrimary),
@@ -84,7 +84,7 @@ class HomePageDrawer extends StatelessWidget {
                               "${I18N.of("今日状态")}: ",
                               style: Theme.of(context)
                                   .textTheme
-                                  .titleMedium
+                                  .titleMedium!
                                   .copyWith(
                                       color: Theme.of(context)
                                           .colorScheme

+ 8 - 8
lib/view/drawer/community/FollowedPage.dart

@@ -27,9 +27,9 @@ class FollowedPage extends StatelessWidget {
 class FollowedPageModel extends BaseModel {
   FollowedPageModel(BuildContext context) : super(context);
 
-  bool isRequesting;
+  late bool isRequesting;
 
-  List data;
+  late List data;
 
   @override
   void init(BuildContext context) {
@@ -44,8 +44,8 @@ class FollowedPageModel extends BaseModel {
     UserProvider userProvider =
         Provider.of<UserProvider>(context, listen: false);
     data.add(userProvider.uid);
-    data.addAll(await Repository.getInstance()
-        .getFollowList(context, userProvider.token, userProvider.uid));
+    data.addAll((await Repository.getInstance()!
+        .getFollowList(context, userProvider.token, userProvider.uid))!);
     isRequesting = false;
     refresh();
   }
@@ -55,20 +55,20 @@ class FollowedPageModel extends BaseModel {
 class FollowedPageService extends BaseProvider {
   FollowedPageService(BuildContext context) : super(context);
 
-  Future<void> onUnFollowed(BuildContext context, int uid) async {
+  Future<void> onUnFollowed(BuildContext context, int? uid) async {
     FollowedPageModel model =
         Provider.of<FollowedPageModel>(context, listen: false);
     UserProvider userProvider =
         Provider.of<UserProvider>(context, listen: false);
-    String res = await PopMenus.userInfo(context: context, uid: uid);
+    String? res = await PopMenus.userInfo(context: context, uid: uid);
     if (res != null) {
       model.data.remove(uid);
       model.isRequesting = true;
       model.refresh();
       model.data.clear();
       model.data.add(userProvider.uid);
-      model.data.addAll(await Repository.getInstance()
-          .getFollowList(context, userProvider.token, userProvider.uid));
+      model.data.addAll((await Repository.getInstance()!
+          .getFollowList(context, userProvider.token, userProvider.uid))!);
       model.isRequesting = false;
       model.refresh();
     }

+ 7 - 7
lib/view/drawer/community/RankingListPage.dart

@@ -12,9 +12,9 @@ class RankingListPage extends StatefulWidget {
 }
 
 class _RankingListPageState extends State<RankingListPage> {
-  bool isRequesting;
+  late bool isRequesting;
 
-  List data;
+  List? data;
 
   @override
   void initState() {
@@ -26,13 +26,13 @@ class _RankingListPageState extends State<RankingListPage> {
   }
 
   Future<void> getData() async {
-    data = await Repository.getInstance().getCoinTop(context, 20);
+    data = await Repository.getInstance()!.getCoinTop(context, 20);
     UserProvider userProvider = Provider.of<UserProvider>(context, listen: false);
-    if (userProvider.uid != null && !data.contains(userProvider.uid)) {
-      data.add(userProvider.uid);
+    if (userProvider.uid != null && !data!.contains(userProvider.uid)) {
+      data!.add(userProvider.uid);
     }
     int rank = 0;
-    data = data.map((i) {
+    data = data!.map((i) {
       rank++;
       if (rank == 21) {
         return {
@@ -61,7 +61,7 @@ class _RankingListPageState extends State<RankingListPage> {
           children: <Widget>[
             isRequesting ? LinearProgressIndicator() : Container(),
             Column(
-              children: data.map((i) {
+              children: data!.map((i) {
                 return UserListTile(
                   uid: i["uid"],
                   trailing: Text("${I18N.of("排名")}: ${i["rank"].toString()}"),

+ 10 - 10
lib/view/drawer/community/SearchUserPage.dart

@@ -13,10 +13,10 @@ class SearchUserPage extends StatefulWidget {
 }
 
 class _SearchUserPageState extends State<SearchUserPage> {
-  bool isRequesting;
-  List res;
+  late bool isRequesting;
+  List? res;
 
-  TextEditingController nameController;
+  TextEditingController? nameController;
 
   @override
   void initState() {
@@ -25,8 +25,8 @@ class _SearchUserPageState extends State<SearchUserPage> {
     isRequesting = false;
     res = [];
     nameController = TextEditingController();
-    nameController.text =
-        Provider.of<UserProvider>(context, listen: false).userName;
+    nameController!.text =
+        Provider.of<UserProvider>(context, listen: false).userName!;
   }
 
   @override
@@ -72,11 +72,11 @@ class _SearchUserPageState extends State<SearchUserPage> {
                         : () async {
                             isRequesting = true;
                             setState(() {});
-                            res.clear();
-                            if (VerifyUtils.isUserName(nameController.text)) {
-                              res = await Repository.getInstance()
+                            res!.clear();
+                            if (VerifyUtils.isUserName(nameController!.text)) {
+                              res = await Repository.getInstance()!
                                   .getUserInfoLikeUserName(
-                                      context, nameController.text);
+                                      context, nameController!.text);
                             }
                             isRequesting = false;
                             setState(() {});
@@ -86,7 +86,7 @@ class _SearchUserPageState extends State<SearchUserPage> {
               ),
             ),
             Column(
-              children: res.map((i) {
+              children: res!.map((i) {
                 return UserListTile(
                   uid: i,
                   onPress: () async {

+ 13 - 13
lib/view/drawer/setting/DataManagementPage.dart

@@ -36,12 +36,12 @@ class DataManagementPage extends StatelessWidget {
 class DataManagementPageModel extends BaseModel {
   DataManagementPageModel(BuildContext context) : super(context);
 
-  bool isRequesting;
+  late bool isRequesting;
 
-  int basicInfoCount;
-  int lifeInfoCount;
-  int exerciseInfoCount;
-  int studyInfoCount;
+  int? basicInfoCount;
+  int? lifeInfoCount;
+  int? exerciseInfoCount;
+  int? studyInfoCount;
 
   @override
   void init(BuildContext context) {
@@ -50,10 +50,10 @@ class DataManagementPageModel extends BaseModel {
 
   @override
   Future<void> asyncInit(BuildContext context) async {
-    basicInfoCount = (await BasicInfoMapper().selectAll()).length;
-    lifeInfoCount = (await LifeInfoMapper().selectAll()).length;
-    exerciseInfoCount = (await ExerciseInfoMapper().selectAll()).length;
-    studyInfoCount = (await StudyInfoMapper().selectAll()).length;
+    basicInfoCount = (await BasicInfoMapper().selectAll())!.length;
+    lifeInfoCount = (await LifeInfoMapper().selectAll())!.length;
+    exerciseInfoCount = (await ExerciseInfoMapper().selectAll())!.length;
+    studyInfoCount = (await StudyInfoMapper().selectAll())!.length;
     isRequesting = false;
     refresh();
   }
@@ -86,14 +86,14 @@ class DataManagementPageService extends BaseProvider {
     model.isRequesting = true;
     model.refresh();
     // 关闭数据库
-    await SqfliteDataBase.getInstance().close();
+    await SqfliteDataBase.getInstance()!.close();
 
     String path = "${await getDatabasesPath()}/${SqfliteDataBase.dbPath}";
     Uint8List data = await File(path).readAsBytes();
     // 上传
     UserProvider userProvider =
         Provider.of<UserProvider>(context, listen: false);
-    bool isSuccess = await Repository.getInstance()
+    bool isSuccess = await Repository.getInstance()!
         .uploadDB(context, userProvider.uid, userProvider.token, data);
     if (isSuccess) {
       await PopMenus.attention(
@@ -114,12 +114,12 @@ class DataManagementPageService extends BaseProvider {
     // 请求
     UserProvider userProvider =
         Provider.of<UserProvider>(context, listen: false);
-    List<int> res = await Repository.getInstance()
+    List<int>? res = await Repository.getInstance()!
         .downloadDB(context, userProvider.uid, userProvider.token);
     if (res != null) {
       // 覆盖数据
       // 关闭数据库
-      await SqfliteDataBase.getInstance().close();
+      await SqfliteDataBase.getInstance()!.close();
 
       String path = "${await getDatabasesPath()}/${SqfliteDataBase.dbPath}";
       File file = File(path);

+ 1 - 1
lib/view/drawer/setting/DebugPage.dart

@@ -59,7 +59,7 @@ class _DebugPageState extends State<DebugPage> {
         ].map((i) {
           return ListTile(
             title: Text(i.name),
-            onTap: i.function,
+            onTap: i.function as void Function()?,
           );
         }).toList(),
       ),

+ 24 - 24
lib/view/drawer/setting/SignTimeSetPage.dart

@@ -33,7 +33,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
               leading: Icon(Icons.wb_sunny),
               title: Text(I18N.of("起床打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.getUpTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.getUpTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.getUpTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.getUpTimeEnd!)}"),
               trailing: Icon(Icons.chevron_right),
               onTap: () async {
                 await PopMenus.baseMenu(
@@ -44,7 +44,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("起始时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
@@ -66,11 +66,11 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("结束时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
-                                  configProvider.getUpTimeEnd)),
+                                  configProvider.getUpTimeEnd!)),
                         );
                         if (res != null) {
                           Navigator.of(context).pop();
@@ -93,7 +93,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
               leading: Icon(Icons.free_breakfast),
               title: Text(I18N.of("早饭打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.breakfastTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.breakfastTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.breakfastTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.breakfastTimeEnd!)}"),
               trailing: Icon(Icons.chevron_right),
               onTap: () async {
                 await PopMenus.baseMenu(
@@ -104,7 +104,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("起始时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
@@ -126,11 +126,11 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("结束时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
-                                  configProvider.breakfastTimeEnd)),
+                                  configProvider.breakfastTimeEnd!)),
                         );
                         if (res != null) {
                           Navigator.of(context).pop();
@@ -153,7 +153,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
               leading: Icon(Icons.local_dining),
               title: Text(I18N.of("午饭打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.lunchTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.lunchTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.lunchTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.lunchTimeEnd!)}"),
               trailing: Icon(Icons.chevron_right),
               onTap: () async {
                 await PopMenus.baseMenu(
@@ -164,7 +164,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("起始时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
@@ -186,11 +186,11 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("结束时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
-                                  configProvider.lunchTimeEnd)),
+                                  configProvider.lunchTimeEnd!)),
                         );
                         if (res != null) {
                           Navigator.of(context).pop();
@@ -213,7 +213,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
               leading: Icon(Icons.local_hotel),
               title: Text(I18N.of("午休打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.midRestTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.midRestTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.midRestTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.midRestTimeEnd!)}"),
               trailing: Icon(Icons.chevron_right),
               onTap: () async {
                 await PopMenus.baseMenu(
@@ -224,7 +224,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("起始时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
@@ -246,11 +246,11 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("结束时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
-                                  configProvider.midRestTimeEnd)),
+                                  configProvider.midRestTimeEnd!)),
                         );
                         if (res != null) {
                           Navigator.of(context).pop();
@@ -273,7 +273,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
               leading: Icon(Icons.restaurant),
               title: Text(I18N.of("晚饭打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.dinnerTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.dinnerTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.dinnerTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.dinnerTimeEnd!)}"),
               trailing: Icon(Icons.chevron_right),
               onTap: () async {
                 await PopMenus.baseMenu(
@@ -284,7 +284,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("起始时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
@@ -306,11 +306,11 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("结束时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
-                                  configProvider.dinnerTimeEnd)),
+                                  configProvider.dinnerTimeEnd!)),
                         );
                         if (res != null) {
                           Navigator.of(context).pop();
@@ -333,7 +333,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
               leading: Icon(Icons.brightness_4),
               title: Text(I18N.of("晚安打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.restTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.restTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.restTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.restTimeEnd!)}"),
               trailing: Icon(Icons.chevron_right),
               onTap: () async {
                 await PopMenus.baseMenu(
@@ -344,7 +344,7 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("起始时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
@@ -366,11 +366,11 @@ class _SignTimeSetPageState extends State<SignTimeSetPage> {
                     TextButton(
                       child: Text(I18N.of("结束时间")),
                       onPressed: () async {
-                        TimeOfDay res = await showTimePicker(
+                        TimeOfDay? res = await showTimePicker(
                           context: context,
                           initialTime: TimeOfDay.fromDateTime(
                               DateTime.fromMillisecondsSinceEpoch(
-                                  configProvider.restTimeEnd)),
+                                  configProvider.restTimeEnd!)),
                         );
                         if (res != null) {
                           Navigator.of(context).pop();

+ 3 - 3
lib/view/drawer/shop/GoodsPage.dart

@@ -16,7 +16,7 @@ class GoodsPage extends StatefulWidget {
 }
 
 class _GoodsPageState extends State<GoodsPage> {
-  bool isRequesting;
+  late bool isRequesting;
 
   @override
   void initState() {
@@ -141,12 +141,12 @@ class _GoodsPageState extends State<GoodsPage> {
                                       listen: false);
                               isRequesting = true;
                               setState(() {});
-                              bool isSuccess = await Repository.getInstance()
+                              bool isSuccess = await Repository.getInstance()!
                                   .buyGoods(context, userProvider.token,
                                       userProvider.uid, widget.data["goodsId"]);
                               if (isSuccess) {
                                 userProvider.coins =
-                                    await Repository.getInstance()
+                                    await Repository.getInstance()!
                                         .getCoin(userProvider.uid);
                                 userProvider.refresh();
                                 await PopMenus.attention(

+ 4 - 4
lib/view/drawer/shop/ShopPage.dart

@@ -11,9 +11,9 @@ class ShopPage extends StatefulWidget {
 }
 
 class _ShopPageState extends State<ShopPage> {
-  bool isRequesting;
+  late bool isRequesting;
 
-  List data;
+  List? data;
 
   @override
   void initState() {
@@ -25,7 +25,7 @@ class _ShopPageState extends State<ShopPage> {
   }
 
   Future<void> loadData() async {
-    data = await Repository.getInstance().getGoodsList(context);
+    data = await Repository.getInstance()!.getGoodsList(context);
     isRequesting = false;
     setState(() {});
   }
@@ -58,7 +58,7 @@ class _ShopPageState extends State<ShopPage> {
           children: <Widget>[
             isRequesting ? LinearProgressIndicator() : Container(),
             Column(
-              children: data.map((i) {
+              children: data!.map((i) {
                 return ListTile(
                   leading: Icon(Icons.shopping_basket),
                   title: Text(

+ 1 - 1
lib/view/drawer/user/UserPage.dart

@@ -68,7 +68,7 @@ class UserPage extends StatelessWidget {
               )
             : ClipOval(
                 child: Image.memory(
-                  userProvider.photo,
+                  userProvider.photo!,
                   width: 150,
                   height: 150,
                 ),

+ 6 - 6
lib/view/drawer/user/setting/CropImagePage.dart

@@ -17,11 +17,11 @@ class CropImagePage extends StatefulWidget {
 }
 
 class _CropImagePageState extends State<CropImagePage> {
-  double baseLeft; //图片左上角的x坐标
-  double baseTop; //图片左上角的y坐标
-  double imageWidth; //图片宽度,缩放后会变化
+  double? baseLeft; //图片左上角的x坐标
+  double? baseTop; //图片左上角的y坐标
+  double? imageWidth; //图片宽度,缩放后会变化
   double imageScale = 1; //图片缩放比例
-  Image imageView;
+  Image? imageView;
 
   final cropKey = GlobalKey<CropState>();
 
@@ -51,9 +51,9 @@ class _CropImagePageState extends State<CropImagePage> {
         child: Icon(Icons.content_cut),
         onPressed: () async {
           File result = await ImageCrop.cropImage(
-              file: widget._image, area: cropKey.currentState.area, scale: 1);
+              file: widget._image, area: cropKey.currentState!.area!, scale: 1);
           List<int> out = await FlutterImageCompress.compressWithList(
-            (await result.readAsBytes()).toList(),
+            (await result.readAsBytes()).toList() as Uint8List,
             minWidth: 200,
             minHeight: 200,
             quality: 95,

+ 16 - 16
lib/view/drawer/user/setting/UserSettingPage.dart

@@ -32,7 +32,7 @@ class UserSettingPage extends StatelessWidget {
 class UserSettingPageModel extends BaseModel {
   UserSettingPageModel(BuildContext context) : super(context);
 
-  bool isRequesting;
+  late bool isRequesting;
 
   @override
   void init(BuildContext context) {
@@ -47,9 +47,9 @@ class UserSettingPageService extends BaseProvider {
 
   Future<void> modifyAndUploadUserInfo(
     BuildContext context, {
-    String userName,
-    String gender,
-    String birthday,
+    String? userName,
+    String? gender,
+    String? birthday,
   }) async {
     UserSettingPageModel model =
         Provider.of<UserSettingPageModel>(context, listen: false);
@@ -57,7 +57,7 @@ class UserSettingPageService extends BaseProvider {
     model.refresh();
     UserProvider userProvider =
         Provider.of<UserProvider>(context, listen: false);
-    bool isSuccess = await Repository.getInstance().modifyUserInfo(
+    bool isSuccess = await Repository.getInstance()!.modifyUserInfo(
       context,
       userProvider.token,
       userProvider.uid,
@@ -86,7 +86,7 @@ class UserSettingPageService extends BaseProvider {
 
     UserProvider userProvider =
         Provider.of<UserProvider>(context, listen: false);
-    bool isSuccess = await Repository.getInstance()
+    bool isSuccess = await Repository.getInstance()!
         .uploadPhoto(context, userProvider.token, userProvider.uid, photo);
     if (isSuccess) {
       userProvider.photo = Uint8List.fromList(photo);
@@ -101,7 +101,7 @@ class UserSettingPageService extends BaseProvider {
   }
 
   Future<void> modifyUserPhoto(BuildContext context) async {
-    List<int> res = await PopMenus.baseMenu(
+    List<int>? res = await PopMenus.baseMenu(
       context: context,
       title: Text(I18N.of("修改头像")),
       children: <Widget>[
@@ -126,10 +126,10 @@ class UserSettingPageService extends BaseProvider {
     }
   }
 
-  Future<List<int>> takePhoto(BuildContext context) async {
-    XFile xfile = await ImagePicker().pickImage(source: ImageSource.camera);
+  Future<List<int>?> takePhoto(BuildContext context) async {
+    XFile? xfile = await ImagePicker().pickImage(source: ImageSource.camera);
     if (xfile != null) {
-      List<int> res = await Navigator.of(context).push(
+      List<int>? res = await Navigator.of(context).push(
           MaterialPageRoute(builder: (_) => CropImagePage(File(xfile.path))));
       if (res != null && res.isNotEmpty) {
         return res;
@@ -138,10 +138,10 @@ class UserSettingPageService extends BaseProvider {
     return null;
   }
 
-  Future<List<int>> pickPhoto(BuildContext context) async {
-    XFile xfile = await ImagePicker().pickImage(source: ImageSource.gallery);
+  Future<List<int>?> pickPhoto(BuildContext context) async {
+    XFile? xfile = await ImagePicker().pickImage(source: ImageSource.gallery);
     if (xfile != null) {
-      List<int> res = await Navigator.of(context).push(
+      List<int>? res = await Navigator.of(context).push(
           MaterialPageRoute(builder: (_) => CropImagePage(File(xfile.path))));
       if (res != null && res.isNotEmpty) {
         return res;
@@ -154,8 +154,8 @@ class UserSettingPageService extends BaseProvider {
     UserProvider userProvider =
         Provider.of<UserProvider>(context, listen: false);
     TextEditingController controller = TextEditingController();
-    controller.text = userProvider.userName;
-    String res = await PopMenus.baseMenu<String>(
+    controller.text = userProvider.userName!;
+    String? res = await PopMenus.baseMenu<String>(
       context: context,
       title: Text(I18N.of("修改用户名")),
       children: <Widget>[
@@ -201,7 +201,7 @@ class UserSettingPageService extends BaseProvider {
   }
 
   Future<void> modifyUserGender(BuildContext context) async {
-    String res = await PopMenus.baseMenu<String>(
+    String? res = await PopMenus.baseMenu<String>(
       context: context,
       title: Text(I18N.of("修改用户名")),
       children: <Widget>[

+ 22 - 22
lib/view/drawer/user/sign/ModifyPwdPage.dart

@@ -27,20 +27,20 @@ class ModifyPwdPage extends StatelessWidget {
 class ModifyPwdPageModel extends BaseModel {
   ModifyPwdPageModel(BuildContext context) : super(context);
 
-  bool isRequesting;
-  bool isPwdVisible;
+  late bool isRequesting;
+  late bool isPwdVisible;
 
-  int counter;
+  int? counter;
 
   GlobalKey emailFormKey = GlobalKey<FormState>();
   GlobalKey pwdFormKey = GlobalKey<FormState>();
 
-  TextEditingController emailController;
-  TextEditingController authCodeController;
-  TextEditingController pwdController;
-  TextEditingController pwdRepeatController;
+  TextEditingController? emailController;
+  TextEditingController? authCodeController;
+  TextEditingController? pwdController;
+  TextEditingController? pwdRepeatController;
 
-  Timer timer;
+  Timer? timer;
 
   @override
   void init(BuildContext context) {
@@ -54,7 +54,7 @@ class ModifyPwdPageModel extends BaseModel {
     pwdFormKey = GlobalKey<FormState>();
 
     emailController = TextEditingController();
-    emailController.text =
+    emailController!.text =
         Provider.of<UserProvider>(context, listen: false).email ?? "";
     authCodeController = TextEditingController();
     pwdController = TextEditingController();
@@ -67,7 +67,7 @@ class ModifyPwdPageModel extends BaseModel {
     
     super.dispose();
     if (timer != null) {
-      timer.cancel();
+      timer!.cancel();
     }
   }
 }
@@ -76,7 +76,7 @@ class ModifyPwdPageModel extends BaseModel {
 class ModifyPwdPageService extends BaseProvider {
   ModifyPwdPageService(BuildContext context) : super(context);
 
-  String validatorEmail(String v) {
+  String? validatorEmail(String? v) {
     if (VerifyUtils.isEmail(v)) {
       return null;
     } else {
@@ -84,7 +84,7 @@ class ModifyPwdPageService extends BaseProvider {
     }
   }
 
-  String validatorPwd(String v) {
+  String? validatorPwd(String? v) {
     if (VerifyUtils.isPassword(v)) {
       return null;
     } else {
@@ -92,10 +92,10 @@ class ModifyPwdPageService extends BaseProvider {
     }
   }
 
-  String validatorPwdRepeat(BuildContext context) {
+  String? validatorPwdRepeat(BuildContext context) {
     ModifyPwdPageModel model =
         Provider.of<ModifyPwdPageModel>(context, listen: false);
-    if (model.pwdController.text == model.pwdRepeatController.text) {
+    if (model.pwdController!.text == model.pwdRepeatController!.text) {
       return null;
     } else {
       return I18N.of("两次输入不一致");
@@ -115,9 +115,9 @@ class ModifyPwdPageService extends BaseProvider {
     model.isRequesting = true;
     model.refresh();
     if ((model.emailFormKey.currentState as FormState).validate()) {
-      bool isSuccess = await Repository.getInstance().sendAuthCode(
+      bool isSuccess = await Repository.getInstance()!.sendAuthCode(
         context,
-        model.emailController.text,
+        model.emailController!.text,
         "RESET_PWD",
       );
       if (isSuccess) {
@@ -137,7 +137,7 @@ class ModifyPwdPageService extends BaseProvider {
       model.counter--;
       model.refresh();
       if (model.counter == 0) {
-        model.timer.cancel();
+        model.timer!.cancel();
       }
     });
   }
@@ -148,14 +148,14 @@ class ModifyPwdPageService extends BaseProvider {
     model.isRequesting = true;
     model.refresh();
     if ((model.pwdFormKey.currentState as FormState).validate()) {
-      bool isSuccess = await Repository.getInstance().resetPwd(
+      bool isSuccess = await Repository.getInstance()!.resetPwd(
         context,
-        model.authCodeController.text,
-        model.emailController.text,
-        model.pwdController.text,
+        model.authCodeController!.text,
+        model.emailController!.text,
+        model.pwdController!.text,
       );
       if (isSuccess) {
-        Navigator.of(context).pop(model.emailController.text);
+        Navigator.of(context).pop(model.emailController!.text);
       }
     }
     model.isRequesting = false;

+ 28 - 28
lib/view/drawer/user/sign/SignInPage.dart

@@ -28,13 +28,13 @@ class SignInPage extends StatelessWidget {
 class SignInPageModel extends BaseModel {
   SignInPageModel(BuildContext context) : super(context);
 
-  bool isRequesting;
-  bool isPwdVisible;
+  late bool isRequesting;
+  late bool isPwdVisible;
 
-  GlobalKey formKey;
+  GlobalKey? formKey;
 
-  TextEditingController emailController;
-  TextEditingController pwdController;
+  TextEditingController? emailController;
+  TextEditingController? pwdController;
 
   @override
   void init(BuildContext context) {
@@ -44,7 +44,7 @@ class SignInPageModel extends BaseModel {
     isPwdVisible = false;
     formKey = GlobalKey<FormState>();
     emailController = TextEditingController();
-    emailController.text =
+    emailController!.text =
         Provider.of<UserProvider>(context, listen: false).email ?? "";
     pwdController = TextEditingController();
   }
@@ -54,7 +54,7 @@ class SignInPageModel extends BaseModel {
 class SignInPageService extends BaseProvider {
   SignInPageService(BuildContext context) : super(context);
 
-  String validatorEmail(String v) {
+  String? validatorEmail(String v) {
     if (v.trim().isEmpty) {
       return I18N.of("邮箱不能为空");
     } else {
@@ -69,7 +69,7 @@ class SignInPageService extends BaseProvider {
     model.refresh();
   }
 
-  String validatorPwd(String v) {
+  String? validatorPwd(String v) {
     if (v.trim().isEmpty) {
       return I18N.of("密码不能为空");
     } else {
@@ -82,23 +82,23 @@ class SignInPageService extends BaseProvider {
         Provider.of<SignInPageModel>(context, listen: false);
     model.isRequesting = true;
     model.refresh();
-    if ((model.formKey.currentState as FormState).validate()) {
-      Map map = await Repository.getInstance().signIn(
+    if ((model.formKey!.currentState as FormState).validate()) {
+      Map? map = await Repository.getInstance()!.signIn(
         context,
-        model.emailController.text,
-        model.pwdController.text,
+        model.emailController!.text,
+        model.pwdController!.text,
       );
       if (map != null && map.isNotEmpty) {
         try {
-          int uid = map["uid"];
-          String token = map["token"];
-          String email = model.emailController.text;
-          Map userInfo = await Repository.getInstance().getUserInfo(uid);
-          String userName = userInfo["userName"];
-          String gender = userInfo["gender"];
-          String birthday = userInfo["birthday"];
-          int coins = await Repository.getInstance().getCoin(uid);
-          List<int> photo = await Repository.getInstance().getPhoto(uid);
+          int? uid = map["uid"];
+          String? token = map["token"];
+          String email = model.emailController!.text;
+          Map userInfo = (await Repository.getInstance()!.getUserInfo(uid))!;
+          String? userName = userInfo["userName"];
+          String? gender = userInfo["gender"];
+          String? birthday = userInfo["birthday"];
+          int? coins = await Repository.getInstance()!.getCoin(uid);
+          List<int> photo = (await Repository.getInstance()!.getPhoto(uid))!;
           UserProvider userProvider =
               Provider.of<UserProvider>(context, listen: false);
           userProvider.uid = uid;
@@ -108,7 +108,7 @@ class SignInPageService extends BaseProvider {
           userProvider.gender = gender;
           userProvider.birthday = birthday;
           userProvider.coins = coins;
-          userProvider.photo = photo.isEmpty ? null : photo;
+          userProvider.photo = photo.isEmpty ? null : photo as Uint8List?;
           userProvider.store();
           userProvider.refresh();
         } catch (e) {
@@ -128,16 +128,16 @@ class SignInPageService extends BaseProvider {
   Future<void> toPwdResetPage(BuildContext context) async {
     SignInPageModel model =
         Provider.of<SignInPageModel>(context, listen: false);
-    model.emailController.text = await Navigator.of(context)
-        .push(MaterialPageRoute(builder: (_) => ModifyPwdPage()));
+    model.emailController!.text = await (Navigator.of(context)
+        .push(MaterialPageRoute(builder: (_) => ModifyPwdPage())) as FutureOr<String>);
     model.refresh();
   }
 
   Future<void> toSignUpPage(BuildContext context) async {
     SignInPageModel model =
         Provider.of<SignInPageModel>(context, listen: false);
-    model.emailController.text = await Navigator.of(context)
-        .push(MaterialPageRoute(builder: (_) => SignUpPage()));
+    model.emailController!.text = await (Navigator.of(context)
+        .push(MaterialPageRoute(builder: (_) => SignUpPage())) as FutureOr<String>);
     model.refresh();
   }
 }
@@ -177,7 +177,7 @@ class _SignInPageView extends StatelessWidget {
                       hintText: I18N.of("请输入您的邮箱"),
                       prefixIcon: Icon(Icons.email),
                     ),
-                    validator: (v) => service.validatorEmail(v),
+                    validator: (v) => service.validatorEmail(v!),
                   ),
                   TextFormField(
                     controller: model.pwdController,
@@ -196,7 +196,7 @@ class _SignInPageView extends StatelessWidget {
                         onPressed: () => service.pwdChangeVisible(context),
                       ),
                     ),
-                    validator: (v) => service.validatorPwd(v),
+                    validator: (v) => service.validatorPwd(v!),
                   ),
                 ],
               ),

+ 21 - 21
lib/view/drawer/user/sign/SignUpPage.dart

@@ -26,20 +26,20 @@ class SignUpPage extends StatelessWidget {
 class SignUpPageModel extends BaseModel {
   SignUpPageModel(BuildContext context) : super(context);
 
-  bool isPwdVisible;
-  bool isRequesting;
+  late bool isPwdVisible;
+  late bool isRequesting;
 
-  int counter;
+  int? counter;
 
   GlobalKey emailFormKey = GlobalKey<FormState>();
   GlobalKey pwdFormKey = GlobalKey<FormState>();
 
-  TextEditingController emailController;
-  TextEditingController authCodeController;
-  TextEditingController pwdController;
-  TextEditingController pwdRepeatController;
+  TextEditingController? emailController;
+  TextEditingController? authCodeController;
+  TextEditingController? pwdController;
+  TextEditingController? pwdRepeatController;
 
-  Timer timer;
+  Timer? timer;
 
   @override
   void init(BuildContext context) {
@@ -60,7 +60,7 @@ class SignUpPageModel extends BaseModel {
     
     super.dispose();
     if (timer != null) {
-      timer.cancel();
+      timer!.cancel();
     }
   }
 }
@@ -69,7 +69,7 @@ class SignUpPageModel extends BaseModel {
 class SignUpPageService extends BaseProvider {
   SignUpPageService(BuildContext context) : super(context);
 
-  String validatorEmail(String v) {
+  String? validatorEmail(String? v) {
     if (VerifyUtils.isEmail(v)) {
       return null;
     } else {
@@ -77,7 +77,7 @@ class SignUpPageService extends BaseProvider {
     }
   }
 
-  String validatorPwd(String v) {
+  String? validatorPwd(String? v) {
     if (VerifyUtils.isPassword(v)) {
       return null;
     } else {
@@ -85,10 +85,10 @@ class SignUpPageService extends BaseProvider {
     }
   }
 
-  String validatorPwdRepeat(BuildContext context) {
+  String? validatorPwdRepeat(BuildContext context) {
     SignUpPageModel model =
         Provider.of<SignUpPageModel>(context, listen: false);
-    if (model.pwdController.text == model.pwdRepeatController.text) {
+    if (model.pwdController!.text == model.pwdRepeatController!.text) {
       return null;
     } else {
       return I18N.of("两次输入不一致");
@@ -108,9 +108,9 @@ class SignUpPageService extends BaseProvider {
     model.isRequesting = true;
     model.refresh();
     if ((model.emailFormKey.currentState as FormState).validate()) {
-      bool isSuccess = await Repository.getInstance().sendAuthCode(
+      bool isSuccess = await Repository.getInstance()!.sendAuthCode(
         context,
-        model.emailController.text,
+        model.emailController!.text,
         "SIGN_UP",
       );
       if (isSuccess) {
@@ -130,7 +130,7 @@ class SignUpPageService extends BaseProvider {
       model.counter--;
       model.refresh();
       if (model.counter == 0) {
-        model.timer.cancel();
+        model.timer!.cancel();
       }
     });
   }
@@ -141,14 +141,14 @@ class SignUpPageService extends BaseProvider {
     model.isRequesting = true;
     model.refresh();
     if ((model.pwdFormKey.currentState as FormState).validate()) {
-      bool isSuccess = await Repository.getInstance().signUp(
+      bool isSuccess = await Repository.getInstance()!.signUp(
         context,
-        model.authCodeController.text,
-        model.emailController.text,
-        model.pwdController.text,
+        model.authCodeController!.text,
+        model.emailController!.text,
+        model.pwdController!.text,
       );
       if (isSuccess) {
-        Navigator.of(context).pop(model.emailController.text);
+        Navigator.of(context).pop(model.emailController!.text);
       }
     }
     model.isRequesting = false;

+ 7 - 7
lib/view/record/AdjustButtonRow.dart

@@ -3,14 +3,14 @@ import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
 
 class SlideAdjuster extends StatefulWidget {
-  final String titleString;
-  final double startValue;
+  final String? titleString;
+  final double? startValue;
   final Function(double value) onValueChange;
 
   SlideAdjuster(
       {this.titleString,
-      @required this.startValue,
-      @required this.onValueChange});
+      required this.startValue,
+      required this.onValueChange});
 
   @override
   _SlideAdjusterState createState() {
@@ -20,7 +20,7 @@ class SlideAdjuster extends StatefulWidget {
 }
 
 class _SlideAdjusterState extends State<SlideAdjuster> {
-  int value;
+  late int value;
 
   double rollValue = 0;
 
@@ -30,7 +30,7 @@ class _SlideAdjusterState extends State<SlideAdjuster> {
   void initState() {
     
     super.initState();
-    value = (widget.startValue * 100).floor();
+    value = (widget.startValue! * 100).floor();
   }
 
   int getAddedValue() {
@@ -50,7 +50,7 @@ class _SlideAdjusterState extends State<SlideAdjuster> {
             icon: Icon(Icons.restore),
             color: Theme.of(context).colorScheme.secondary,
             onPressed: () {
-              value = (widget.startValue * 100).floor();
+              value = (widget.startValue! * 100).floor();
               widget.onValueChange(value / 100);
               setState(() {});
             },

+ 8 - 8
lib/view/record/BasicInfoRecordingPage.dart

@@ -30,11 +30,11 @@ class BasicInfoRecordingPage extends StatelessWidget {
 // model
 class BasicInfoRecordingPageModel extends BaseModel {
   BasicInfoRecordingPageModel(BuildContext context) : super(context);
-  double height;
-  double weight;
-  double breastLine;
-  double waistLine;
-  double hipLine;
+  double? height;
+  double? weight;
+  double? breastLine;
+  double? waistLine;
+  double? hipLine;
 
   @override
   void init(BuildContext context) {
@@ -59,8 +59,8 @@ class BasicInfoRecordingPageService extends BaseProvider {
         Provider.of<BasicInfoRecordingPageModel>(context, listen: false);
     // 今日是否记录过
     DateTime now = DateTime.now();
-    List<BasicInfo> list = await BasicInfoMapper().selectWhere(
-        "date >= ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}");
+    List<BasicInfo> list = (await BasicInfoMapper().selectWhere(
+        "date >= ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}"))!;
     BasicInfo basicInfo = BasicInfo();
     basicInfo.setHeight(model.height);
     basicInfo.setWeight(model.weight);
@@ -92,7 +92,7 @@ class BasicInfoRecordingPageService extends BaseProvider {
           Provider.of<UserProvider>(context, listen: false);
       if (userProvider.token != null) {
         // 增加金币
-        int increasedCoin = await Repository.getInstance()
+        int? increasedCoin = await Repository.getInstance()!
             .increaseCoin(context, userProvider.uid, userProvider.token);
         if (increasedCoin != null) {
           await PopMenus.coinAdd(context: context, addedCoins: increasedCoin);

+ 14 - 14
lib/view/record/ExerciseInfoRecordingPage.dart

@@ -18,7 +18,7 @@ class ExerciseInfoRecordingPage extends StatefulWidget {
 }
 
 class _ExerciseInfoRecordingPageState extends State<ExerciseInfoRecordingPage> {
-  List<SportInfo> spots;
+  List<SportInfo>? spots;
 
   @override
   void initState() {
@@ -36,9 +36,9 @@ class _ExerciseInfoRecordingPageState extends State<ExerciseInfoRecordingPage> {
 
   Future<void> onSelected(SportInfo sportInfo) async {
     TextEditingController intakeController = TextEditingController();
-    List res = await PopMenus.baseMenu<List>(
+    List? res = await PopMenus.baseMenu<List>(
       context: context,
-      title: Text(sportInfo.getName()),
+      title: Text(sportInfo.getName()!),
       children: <Widget>[
         Divider(),
         Text("${I18N.of("运动次数")}: ${sportInfo.getSportTimes()}"),
@@ -85,15 +85,15 @@ class _ExerciseInfoRecordingPageState extends State<ExerciseInfoRecordingPage> {
       exerciseInfo.setExerciseQuantity(res[1]);
       exerciseInfo.setExerciseTime(now.millisecondsSinceEpoch);
       // 今日首次运动?
-      List<ExerciseInfo> localExerciseInfo = await ExerciseInfoMapper().selectWhere(
-          "exerciseTime > ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}");
+      List<ExerciseInfo> localExerciseInfo = (await ExerciseInfoMapper().selectWhere(
+          "exerciseTime > ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}"))!;
       if (localExerciseInfo.isEmpty){
         // 今日首次运动
         // 增加金币
         UserProvider userProvider =
         Provider.of<UserProvider>(context, listen: false);
         if (userProvider.token != null) {
-          int increasedCoin = await Repository.getInstance()
+          int? increasedCoin = await Repository.getInstance()!
               .increaseCoin(context, userProvider.uid, userProvider.token);
           if (increasedCoin != null) {
             await PopMenus.coinAdd(
@@ -118,13 +118,13 @@ class _ExerciseInfoRecordingPageState extends State<ExerciseInfoRecordingPage> {
           IconButton(
             icon: Icon(Icons.search),
             onPressed: () async {
-              String name = await showSearch<String>(
+              String? name = await showSearch<String?>(
                 context: context,
                 delegate: _SportSearchDelegate(spots),
               );
               await loadData();
               List<SportInfo> list =
-                  spots.where((test) => test.getName() == name).toList();
+                  spots!.where((test) => test.getName() == name).toList();
               if (list.isNotEmpty) {
                 await onSelected(list.last);
               }
@@ -206,9 +206,9 @@ class _ExerciseInfoRecordingPageState extends State<ExerciseInfoRecordingPage> {
             ),
             Expanded(
               child: ListView(
-                children: spots.map((i) {
+                children: spots!.map((i) {
                   return ListTile(
-                    title: Text(i.getName()),
+                    title: Text(i.getName()!),
                     subtitle: Text(
                         "${I18N.of("消耗热量")}: ${i.getHkCalorie()} (h/kcal)"),
                     trailing: Text("${I18N.of("运动次数")}: ${i.getSportTimes()}"),
@@ -245,8 +245,8 @@ class _ExerciseInfoRecordingPageState extends State<ExerciseInfoRecordingPage> {
   }
 }
 
-class _SportSearchDelegate extends SearchDelegate<String> {
-  List<SportInfo> spots;
+class _SportSearchDelegate extends SearchDelegate<String?> {
+  List<SportInfo>? spots;
 
   _SportSearchDelegate(this.spots);
 
@@ -281,9 +281,9 @@ class _SportSearchDelegate extends SearchDelegate<String> {
       padding: EdgeInsets.all(16),
       child: ListView(
         children:
-            spots.where((test) => test.getName().contains(query)).map((i) {
+            spots!.where((test) => test.getName()!.contains(query)).map((i) {
           return ListTile(
-            title: Text(i.getName()),
+            title: Text(i.getName()!),
             subtitle: Text("${I18N.of("消耗热量")}: ${i.getHkCalorie()} (h/kcal)"),
             trailing: Text("${I18N.of("运动次数")}: ${i.getSportTimes()}"),
             onTap: () {

+ 26 - 26
lib/view/record/LifeInfoRecordingPage.dart

@@ -34,13 +34,13 @@ class LifeInfoRecordingPage extends StatelessWidget {
 class LifeInfoRecordingPageModel extends BaseModel {
   LifeInfoRecordingPageModel(BuildContext context) : super(context);
 
-  int currId;
-  bool isSignGetUp;
-  bool isSignBreakfast;
-  bool isSignMidRest;
-  bool isSignLunch;
-  bool isSignDinner;
-  bool isSignRest;
+  int? currId;
+  late bool isSignGetUp;
+  late bool isSignBreakfast;
+  late bool isSignMidRest;
+  late bool isSignLunch;
+  late bool isSignDinner;
+  late bool isSignRest;
 
   @override
   void init(BuildContext context) {
@@ -58,8 +58,8 @@ class LifeInfoRecordingPageModel extends BaseModel {
   @override
   Future<void> asyncInit(BuildContext context) async {
     DateTime now = DateTime.now();
-    List<LifeInfo> list = await LifeInfoMapper().selectWhere(
-        "date >= ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}");
+    List<LifeInfo> list = (await LifeInfoMapper().selectWhere(
+        "date >= ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}"))!;
     if (list.isNotEmpty) {
       LifeInfo localLifeInfo = list[0];
       currId = list[0].getId();
@@ -72,8 +72,8 @@ class LifeInfoRecordingPageModel extends BaseModel {
     } else {
       await LifeInfoMapper()
           .insert(LifeInfo().setDate(now.millisecondsSinceEpoch));
-      list = await LifeInfoMapper().selectWhere(
-          "date >= ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}");
+      list = (await LifeInfoMapper().selectWhere(
+          "date >= ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}"))!;
       currId = list[0].getId();
       isSignGetUp = false;
       isSignBreakfast = false;
@@ -116,7 +116,7 @@ class LifeInfoRecordingPageService extends BaseProvider {
           UserProvider userProvider =
               Provider.of<UserProvider>(context, listen: false);
           if (userProvider.token != null) {
-            int increasedCoin = await Repository.getInstance()
+            int? increasedCoin = await Repository.getInstance()!
                 .increaseCoin(context, userProvider.uid, userProvider.token);
             if (increasedCoin != null) {
               await PopMenus.coinAdd(
@@ -138,7 +138,7 @@ class LifeInfoRecordingPageService extends BaseProvider {
         Provider.of<LifeInfoRecordingPageModel>(context, listen: false);
     ConfigProvider configProvider =
         Provider.of<ConfigProvider>(context, listen: false);
-    List info = await Navigator.of(context)
+    List? info = await Navigator.of(context)
         .push(MaterialPageRoute(builder: (_) => FoodRecordPage()));
     if (info != null) {
       LifeInfo lifeInfo = LifeInfo();
@@ -164,7 +164,7 @@ class LifeInfoRecordingPageService extends BaseProvider {
         UserProvider userProvider =
             Provider.of<UserProvider>(context, listen: false);
         if (userProvider.token != null) {
-          int increasedCoin = await Repository.getInstance()
+          int? increasedCoin = await Repository.getInstance()!
               .increaseCoin(context, userProvider.uid, userProvider.token);
           if (increasedCoin != null) {
             await PopMenus.coinAdd(context: context, addedCoins: increasedCoin);
@@ -184,7 +184,7 @@ class LifeInfoRecordingPageService extends BaseProvider {
         Provider.of<LifeInfoRecordingPageModel>(context, listen: false);
     ConfigProvider configProvider =
         Provider.of<ConfigProvider>(context, listen: false);
-    List info = await Navigator.of(context)
+    List? info = await Navigator.of(context)
         .push(MaterialPageRoute(builder: (_) => FoodRecordPage()));
     if (info != null) {
       LifeInfo lifeInfo = LifeInfo();
@@ -210,7 +210,7 @@ class LifeInfoRecordingPageService extends BaseProvider {
         UserProvider userProvider =
             Provider.of<UserProvider>(context, listen: false);
         if (userProvider.token != null) {
-          int increasedCoin = await Repository.getInstance()
+          int? increasedCoin = await Repository.getInstance()!
               .increaseCoin(context, userProvider.uid, userProvider.token);
           if (increasedCoin != null) {
             await PopMenus.coinAdd(context: context, addedCoins: increasedCoin);
@@ -230,7 +230,7 @@ class LifeInfoRecordingPageService extends BaseProvider {
         Provider.of<LifeInfoRecordingPageModel>(context, listen: false);
     ConfigProvider configProvider =
         Provider.of<ConfigProvider>(context, listen: false);
-    List info = await Navigator.of(context)
+    List? info = await Navigator.of(context)
         .push(MaterialPageRoute(builder: (_) => FoodRecordPage()));
     if (info != null) {
       LifeInfo lifeInfo = LifeInfo();
@@ -256,7 +256,7 @@ class LifeInfoRecordingPageService extends BaseProvider {
         UserProvider userProvider =
             Provider.of<UserProvider>(context, listen: false);
         if (userProvider.token != null) {
-          int increasedCoin = await Repository.getInstance()
+          int? increasedCoin = await Repository.getInstance()!
               .increaseCoin(context, userProvider.uid, userProvider.token);
           if (increasedCoin != null) {
             await PopMenus.coinAdd(context: context, addedCoins: increasedCoin);
@@ -296,7 +296,7 @@ class LifeInfoRecordingPageService extends BaseProvider {
           UserProvider userProvider =
               Provider.of<UserProvider>(context, listen: false);
           if (userProvider.token != null) {
-            int increasedCoin = await Repository.getInstance()
+            int? increasedCoin = await Repository.getInstance()!
                 .increaseCoin(context, userProvider.uid, userProvider.token);
             if (increasedCoin != null) {
               await PopMenus.coinAdd(
@@ -338,7 +338,7 @@ class LifeInfoRecordingPageService extends BaseProvider {
           UserProvider userProvider =
               Provider.of<UserProvider>(context, listen: false);
           if (userProvider.token != null) {
-            int increasedCoin = await Repository.getInstance()
+            int? increasedCoin = await Repository.getInstance()!
                 .increaseCoin(context, userProvider.uid, userProvider.token);
             if (increasedCoin != null) {
               await PopMenus.coinAdd(
@@ -378,7 +378,7 @@ class _LifeInfoRecordingPageView extends StatelessWidget {
               leading: Icon(Icons.wb_sunny),
               title: Text(I18N.of("起床打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.getUpTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.getUpTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.getUpTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.getUpTimeEnd!)}"),
               trailing: Icon(
                 model.isSignGetUp ? Icons.check_circle : Icons.chevron_right,
                 color: model.isSignGetUp
@@ -392,7 +392,7 @@ class _LifeInfoRecordingPageView extends StatelessWidget {
               leading: Icon(Icons.free_breakfast),
               title: Text(I18N.of("早饭打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.breakfastTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.breakfastTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.breakfastTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.breakfastTimeEnd!)}"),
               trailing: Icon(
                 model.isSignBreakfast
                     ? Icons.check_circle
@@ -409,7 +409,7 @@ class _LifeInfoRecordingPageView extends StatelessWidget {
               leading: Icon(Icons.local_dining),
               title: Text(I18N.of("午饭打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.lunchTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.lunchTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.lunchTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.lunchTimeEnd!)}"),
               trailing: Icon(
                 model.isSignLunch ? Icons.check_circle : Icons.chevron_right,
                 color: model.isSignLunch
@@ -423,7 +423,7 @@ class _LifeInfoRecordingPageView extends StatelessWidget {
               leading: Icon(Icons.local_hotel),
               title: Text(I18N.of("午休打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.midRestTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.midRestTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.midRestTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.midRestTimeEnd!)}"),
               trailing: Icon(
                 model.isSignMidRest ? Icons.check_circle : Icons.chevron_right,
                 color:
@@ -439,7 +439,7 @@ class _LifeInfoRecordingPageView extends StatelessWidget {
               leading: Icon(Icons.restaurant),
               title: Text(I18N.of("晚饭打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.dinnerTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.dinnerTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.dinnerTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.dinnerTimeEnd!)}"),
               trailing: Icon(
                 model.isSignDinner ? Icons.check_circle : Icons.chevron_right,
                 color:
@@ -454,7 +454,7 @@ class _LifeInfoRecordingPageView extends StatelessWidget {
               leading: Icon(Icons.brightness_4),
               title: Text(I18N.of("晚安打卡")),
               subtitle: Text(
-                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.restTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.restTimeEnd)}"),
+                  "${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.restTimeStart)} - ${ConvertUtils.timeFormMillisecondsSinceEpoch(configProvider.restTimeEnd!)}"),
               trailing: Icon(
                 model.isSignRest ? Icons.check_circle : Icons.chevron_right,
                 color: model.isSignRest

+ 19 - 19
lib/view/record/StudyInfoRecordingPage.dart

@@ -30,14 +30,14 @@ class StudyInfoRecordingPage extends StatelessWidget {
 class StudyInfoRecordingPageModel extends BaseModel {
   StudyInfoRecordingPageModel(BuildContext context) : super(context);
 
-  TextEditingController courseNameController;
+  TextEditingController? courseNameController;
 
-  int isLate;
-  int isAbsent;
-  int isHomeWorkDone;
-  TextEditingController homeWorkController;
-  int difficulty;
-  TextEditingController troubleController;
+  int? isLate;
+  int? isAbsent;
+  int? isHomeWorkDone;
+  TextEditingController? homeWorkController;
+  int? difficulty;
+  TextEditingController? troubleController;
 
   @override
   void init(BuildContext context) {
@@ -57,7 +57,7 @@ class StudyInfoRecordingPageModel extends BaseModel {
 class StudyInfoRecordingPageService extends BaseProvider {
   StudyInfoRecordingPageService(BuildContext context) : super(context);
 
-  void setIsLate(BuildContext context, int i) {
+  void setIsLate(BuildContext context, int? i) {
     StudyInfoRecordingPageModel model =
         Provider.of<StudyInfoRecordingPageModel>(context, listen: false);
     model.isLate = i;
@@ -67,7 +67,7 @@ class StudyInfoRecordingPageService extends BaseProvider {
     model.refresh();
   }
 
-  void setIsAbsent(BuildContext context, int i) {
+  void setIsAbsent(BuildContext context, int? i) {
     StudyInfoRecordingPageModel model =
         Provider.of<StudyInfoRecordingPageModel>(context, listen: false);
     model.isAbsent = i;
@@ -77,14 +77,14 @@ class StudyInfoRecordingPageService extends BaseProvider {
     model.refresh();
   }
 
-  void setIsHomeWorkDone(BuildContext context, int i) {
+  void setIsHomeWorkDone(BuildContext context, int? i) {
     StudyInfoRecordingPageModel model =
         Provider.of<StudyInfoRecordingPageModel>(context, listen: false);
     model.isHomeWorkDone = i;
     model.refresh();
   }
 
-  void setDifficulty(BuildContext context, int i) {
+  void setDifficulty(BuildContext context, int? i) {
     StudyInfoRecordingPageModel model =
         Provider.of<StudyInfoRecordingPageModel>(context, listen: false);
     model.difficulty = i;
@@ -100,7 +100,7 @@ class StudyInfoRecordingPageService extends BaseProvider {
                 title: Text(I18N.of("MarkDown预览")),
               ),
               body: Markdown(
-                data: model.troubleController.text.toString(),
+                data: model.troubleController!.text.toString(),
               ),
             )));
   }
@@ -108,37 +108,37 @@ class StudyInfoRecordingPageService extends BaseProvider {
   Future<void> record(BuildContext context) async {
     StudyInfoRecordingPageModel model =
         Provider.of<StudyInfoRecordingPageModel>(context, listen: false);
-    if (model.courseNameController.text.trim().isEmpty) {
+    if (model.courseNameController!.text.trim().isEmpty) {
       await PopMenus.attention(context: context,content: Text(I18N.of("课程主题不能为空")));
       return;
     }
     DateTime now = DateTime.now();
     StudyInfo studyInfo = StudyInfo();
     studyInfo.setDate(now.millisecondsSinceEpoch);
-    studyInfo.setCourseName(model.courseNameController.text);
+    studyInfo.setCourseName(model.courseNameController!.text);
     studyInfo.setIsLate(model.isLate);
     studyInfo.setIsAbsent(model.isAbsent);
     studyInfo.setIsHomeWorkDone(model.isHomeWorkDone);
     if (model.isHomeWorkDone == 0) {
-      studyInfo.setHomeworks(model.homeWorkController.text);
+      studyInfo.setHomeworks(model.homeWorkController!.text);
     }
     studyInfo.setDifficulty(model.difficulty);
     studyInfo.setIsTroublesSolved(1);
     if (model.difficulty == 2) {
       studyInfo.setIsTroublesSolved(0);
-      studyInfo.setTroubles(model.troubleController.text);
+      studyInfo.setTroubles(model.troubleController!.text);
     }
 
     // 今日首次?
-    List<StudyInfo> localStudyInfo = await StudyInfoMapper().selectWhere(
-        "date > ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}");
+    List<StudyInfo> localStudyInfo = (await StudyInfoMapper().selectWhere(
+        "date > ${ConvertUtils.dateOfDateTime(now).millisecondsSinceEpoch}"))!;
     if (localStudyInfo.isEmpty){
       // 今日首次
       // 增加金币
       UserProvider userProvider =
       Provider.of<UserProvider>(context, listen: false);
       if (userProvider.token != null) {
-        int increasedCoin = await Repository.getInstance()
+        int? increasedCoin = await Repository.getInstance()!
             .increaseCoin(context, userProvider.uid, userProvider.token);
         if (increasedCoin != null) {
           await PopMenus.coinAdd(

+ 12 - 12
lib/view/record/sub/AddScheduledExercisePage.dart

@@ -15,7 +15,7 @@ class AddScheduledExercisePage extends StatefulWidget {
 }
 
 class _AddScheduledExercisePageState extends State<AddScheduledExercisePage> {
-  List<SportInfo> spots;
+  List<SportInfo>? spots;
 
   @override
   void initState() {
@@ -33,9 +33,9 @@ class _AddScheduledExercisePageState extends State<AddScheduledExercisePage> {
 
   Future<void> onSelected(SportInfo sportInfo) async {
     TextEditingController intakeController = TextEditingController();
-    String res = await PopMenus.baseMenu(
+    String? res = await PopMenus.baseMenu(
       context: context,
-      title: Text(sportInfo.getName()),
+      title: Text(sportInfo.getName()!),
       children: <Widget>[
         Divider(),
         Text("${I18N.of("运动次数")}: ${sportInfo.getSportTimes()}"),
@@ -58,7 +58,7 @@ class _AddScheduledExercisePageState extends State<AddScheduledExercisePage> {
               // 更新次数
               SportInfo s = SportInfo();
               s.setId(sportInfo.getId());
-              s.setSportTimes(sportInfo.getSportTimes() + 1);
+              s.setSportTimes(sportInfo.getSportTimes()! + 1);
               await SportInfoMapper().updateByFirstKeySelective(s);
 
               // 插入计划
@@ -94,13 +94,13 @@ class _AddScheduledExercisePageState extends State<AddScheduledExercisePage> {
           IconButton(
             icon: Icon(Icons.search),
             onPressed: () async {
-              String name = await showSearch<String>(
+              String? name = await showSearch<String?>(
                 context: context,
                 delegate: _SportSearchDelegate(spots),
               );
               await loadData();
               List<SportInfo> list =
-                  spots.where((test) => test.getName() == name).toList();
+                  spots!.where((test) => test.getName() == name).toList();
               if (list.isNotEmpty) {
                 await onSelected(list.last);
               }
@@ -182,9 +182,9 @@ class _AddScheduledExercisePageState extends State<AddScheduledExercisePage> {
             ),
             Expanded(
               child: ListView(
-                children: spots.map((i) {
+                children: spots!.map((i) {
                   return ListTile(
-                    title: Text(i.getName()),
+                    title: Text(i.getName()!),
                     subtitle: Text(
                         "${I18N.of("消耗热量")}: ${i.getHkCalorie()} (h/kcal)"),
                     trailing: Text("${I18N.of("运动次数")}: ${i.getSportTimes()}"),
@@ -221,8 +221,8 @@ class _AddScheduledExercisePageState extends State<AddScheduledExercisePage> {
   }
 }
 
-class _SportSearchDelegate extends SearchDelegate<String> {
-  List<SportInfo> spots;
+class _SportSearchDelegate extends SearchDelegate<String?> {
+  List<SportInfo>? spots;
 
   _SportSearchDelegate(this.spots);
 
@@ -257,9 +257,9 @@ class _SportSearchDelegate extends SearchDelegate<String> {
       padding: EdgeInsets.all(16),
       child: ListView(
         children:
-            spots.where((test) => test.getName().contains(query)).map((i) {
+            spots!.where((test) => test.getName()!.contains(query)).map((i) {
           return ListTile(
-            title: Text(i.getName()),
+            title: Text(i.getName()!),
             subtitle: Text("${I18N.of("消耗热量")}: ${i.getHkCalorie()} (h/kcal)"),
             trailing: Text("${I18N.of("运动次数")}: ${i.getSportTimes()}"),
             onTap: () {

+ 11 - 11
lib/view/record/sub/FoodRecordPage.dart

@@ -10,7 +10,7 @@ class FoodRecordPage extends StatefulWidget {
 }
 
 class _FoodRecordPageState extends State<FoodRecordPage> {
-  List<FoodInfo> foods;
+  List<FoodInfo>? foods;
 
   @override
   void initState() {
@@ -29,9 +29,9 @@ class _FoodRecordPageState extends State<FoodRecordPage> {
   Future<void> onSelected(FoodInfo foodInfo) async {
     TextEditingController intakeController = TextEditingController();
     TextEditingController moneyController = TextEditingController();
-    List res = await PopMenus.baseMenu<List>(
+    List? res = await PopMenus.baseMenu<List>(
       context: context,
-      title: Text(foodInfo.getName()),
+      title: Text(foodInfo.getName()!),
       children: <Widget>[
         Divider(),
         Text("${I18N.of("食用次数")}: ${foodInfo.getEatTimes()}"),
@@ -89,13 +89,13 @@ class _FoodRecordPageState extends State<FoodRecordPage> {
           IconButton(
             icon: Icon(Icons.search),
             onPressed: () async {
-              String name = await showSearch<String>(
+              String? name = await showSearch<String?>(
                 context: context,
                 delegate: _FoodSearchDelegate(foods),
               );
               await loadData();
               List<FoodInfo> list =
-                  foods.where((test) => test.getName() == name).toList();
+                  foods!.where((test) => test.getName() == name).toList();
               if (list.isNotEmpty) {
                 await onSelected(list.last);
               }
@@ -177,9 +177,9 @@ class _FoodRecordPageState extends State<FoodRecordPage> {
             ),
             Expanded(
               child: ListView(
-                children: foods.map((i) {
+                children: foods!.map((i) {
                   return ListTile(
-                    title: Text(i.getName()),
+                    title: Text(i.getName()!),
                     subtitle: Text(
                         "${I18N.of("食物热量")}: ${i.getHgkCalorie()} (100g/kcal)"),
                     trailing: Text("${I18N.of("食用次数")}: ${i.getEatTimes()}"),
@@ -216,8 +216,8 @@ class _FoodRecordPageState extends State<FoodRecordPage> {
   }
 }
 
-class _FoodSearchDelegate extends SearchDelegate<String> {
-  List<FoodInfo> foods;
+class _FoodSearchDelegate extends SearchDelegate<String?> {
+  List<FoodInfo>? foods;
 
   _FoodSearchDelegate(this.foods);
 
@@ -252,9 +252,9 @@ class _FoodSearchDelegate extends SearchDelegate<String> {
       padding: EdgeInsets.all(16),
       child: ListView(
         children:
-            foods.where((test) => test.getName().contains(query)).map((i) {
+            foods!.where((test) => test.getName()!.contains(query)).map((i) {
           return ListTile(
-            title: Text(i.getName()),
+            title: Text(i.getName()!),
             subtitle:
                 Text("${I18N.of("食物热量")}: ${i.getHgkCalorie()} (100g/kcal)"),
             trailing: Text("${I18N.of("食用次数")}: ${i.getEatTimes()}"),

+ 1 - 1
pubspec.yaml

@@ -3,7 +3,7 @@ description: A new Flutter application.
 version: 1.2.3+1
 
 environment:
-  sdk: '>=2.7.0 <3.0.0'
+  sdk: '>=2.19.2 <3.0.0'
 
 dependencies:
   flutter: