Commit 8616f94b30284390ff48d45a1338f7f71ad3fc64
1 parent
07b173c9
feat:sp持久化key收入各业务内部
Showing
3 changed files
with
11 additions
and
14 deletions
lib/common/core/app_config_helper.dart
1 | -import 'dart:ffi'; | |
2 | 1 | import 'dart:io'; |
3 | 2 | |
4 | 3 | import 'package:flutter/cupertino.dart'; |
5 | 4 | import 'package:flutter/foundation.dart'; |
6 | 5 | import 'package:flutter/services.dart'; |
7 | 6 | import 'package:package_info_plus/package_info_plus.dart'; |
8 | -import 'package:wow_english/common/core/sp_const.dart'; | |
9 | 7 | import 'package:wow_english/common/core/user_util.dart'; |
10 | 8 | |
11 | 9 | import '../../models/app_config_entity.dart'; |
... | ... | @@ -14,6 +12,8 @@ import '../request/dao/system_dao.dart'; |
14 | 12 | |
15 | 13 | class AppConfigHelper { |
16 | 14 | |
15 | + static const String _prefsKeyAgreementAccepted = "privacy_agreement_accepted"; | |
16 | + | |
17 | 17 | static AppConfigEntity? configEntityEntity; |
18 | 18 | |
19 | 19 | static String _versionCode = ''; |
... | ... | @@ -56,15 +56,15 @@ class AppConfigHelper { |
56 | 56 | } |
57 | 57 | |
58 | 58 | static void saveAgreementAccepted(bool accepted) { |
59 | - SpUtil.getInstance().setData(SpConst.prefsKeyAgreementAccepted, accepted); | |
59 | + SpUtil.getInstance().setData(_prefsKeyAgreementAccepted, accepted); | |
60 | 60 | } |
61 | 61 | |
62 | 62 | static bool getAgreementAccepted() { |
63 | - return SpUtil.getInstance().get<bool>(SpConst.prefsKeyAgreementAccepted) ?? false; | |
63 | + return SpUtil.getInstance().get<bool>(_prefsKeyAgreementAccepted) ?? false; | |
64 | 64 | } |
65 | 65 | |
66 | 66 | static void _clearUserData() { |
67 | - SpUtil.getInstance().remove(SpConst.prefsKeyAgreementAccepted); | |
67 | + SpUtil.getInstance().remove(_prefsKeyAgreementAccepted); | |
68 | 68 | } |
69 | 69 | |
70 | 70 | static void exitApp() { | ... | ... |
lib/common/core/sp_const.dart deleted
lib/common/core/user_util.dart
... | ... | @@ -2,7 +2,6 @@ import 'dart:convert'; |
2 | 2 | |
3 | 3 | import 'package:flutter/foundation.dart'; |
4 | 4 | import 'package:umeng_common_sdk/umeng_common_sdk.dart'; |
5 | -import 'package:wow_english/common/core/sp_const.dart'; | |
6 | 5 | import 'package:wow_english/models/user_entity.dart'; |
7 | 6 | import 'package:wow_english/route/route.dart'; |
8 | 7 | import 'package:wow_english/utils/sp_util.dart'; |
... | ... | @@ -10,6 +9,9 @@ import 'package:wow_english/utils/sp_util.dart'; |
10 | 9 | import '../../utils/audio_player_util.dart'; |
11 | 10 | |
12 | 11 | class UserUtil { |
12 | + | |
13 | + static const String _prefsKeyUserInfo = "key_user_info"; | |
14 | + | |
13 | 15 | static UserEntity? _userEntity; |
14 | 16 | |
15 | 17 | static void saveUser(UserEntity? user) { |
... | ... | @@ -41,16 +43,16 @@ class UserUtil { |
41 | 43 | } |
42 | 44 | |
43 | 45 | static void _saveUserJson(String userJson) { |
44 | - SpUtil.getInstance().setData(SpConst.prefsKeyUserInfo, userJson); | |
46 | + SpUtil.getInstance().setData(_prefsKeyUserInfo, userJson); | |
45 | 47 | } |
46 | 48 | |
47 | 49 | static String? _getUserJson() { |
48 | - return SpUtil.getInstance().get<String>(SpConst.prefsKeyUserInfo); | |
50 | + return SpUtil.getInstance().get<String>(_prefsKeyUserInfo); | |
49 | 51 | } |
50 | 52 | |
51 | 53 | static void _clearUserData() { |
52 | 54 | _userEntity = null; |
53 | - SpUtil.getInstance().remove(SpConst.prefsKeyUserInfo); | |
55 | + SpUtil.getInstance().remove(_prefsKeyUserInfo); | |
54 | 56 | } |
55 | 57 | |
56 | 58 | static void logout([bool showPasswordLoginPage = false]) { | ... | ... |