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 | import 'dart:io'; | 1 | import 'dart:io'; |
3 | 2 | ||
4 | import 'package:flutter/cupertino.dart'; | 3 | import 'package:flutter/cupertino.dart'; |
5 | import 'package:flutter/foundation.dart'; | 4 | import 'package:flutter/foundation.dart'; |
6 | import 'package:flutter/services.dart'; | 5 | import 'package:flutter/services.dart'; |
7 | import 'package:package_info_plus/package_info_plus.dart'; | 6 | import 'package:package_info_plus/package_info_plus.dart'; |
8 | -import 'package:wow_english/common/core/sp_const.dart'; | ||
9 | import 'package:wow_english/common/core/user_util.dart'; | 7 | import 'package:wow_english/common/core/user_util.dart'; |
10 | 8 | ||
11 | import '../../models/app_config_entity.dart'; | 9 | import '../../models/app_config_entity.dart'; |
@@ -14,6 +12,8 @@ import '../request/dao/system_dao.dart'; | @@ -14,6 +12,8 @@ import '../request/dao/system_dao.dart'; | ||
14 | 12 | ||
15 | class AppConfigHelper { | 13 | class AppConfigHelper { |
16 | 14 | ||
15 | + static const String _prefsKeyAgreementAccepted = "privacy_agreement_accepted"; | ||
16 | + | ||
17 | static AppConfigEntity? configEntityEntity; | 17 | static AppConfigEntity? configEntityEntity; |
18 | 18 | ||
19 | static String _versionCode = ''; | 19 | static String _versionCode = ''; |
@@ -56,15 +56,15 @@ class AppConfigHelper { | @@ -56,15 +56,15 @@ class AppConfigHelper { | ||
56 | } | 56 | } |
57 | 57 | ||
58 | static void saveAgreementAccepted(bool accepted) { | 58 | static void saveAgreementAccepted(bool accepted) { |
59 | - SpUtil.getInstance().setData(SpConst.prefsKeyAgreementAccepted, accepted); | 59 | + SpUtil.getInstance().setData(_prefsKeyAgreementAccepted, accepted); |
60 | } | 60 | } |
61 | 61 | ||
62 | static bool getAgreementAccepted() { | 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 | static void _clearUserData() { | 66 | static void _clearUserData() { |
67 | - SpUtil.getInstance().remove(SpConst.prefsKeyAgreementAccepted); | 67 | + SpUtil.getInstance().remove(_prefsKeyAgreementAccepted); |
68 | } | 68 | } |
69 | 69 | ||
70 | static void exitApp() { | 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,7 +2,6 @@ import 'dart:convert'; | ||
2 | 2 | ||
3 | import 'package:flutter/foundation.dart'; | 3 | import 'package:flutter/foundation.dart'; |
4 | import 'package:umeng_common_sdk/umeng_common_sdk.dart'; | 4 | import 'package:umeng_common_sdk/umeng_common_sdk.dart'; |
5 | -import 'package:wow_english/common/core/sp_const.dart'; | ||
6 | import 'package:wow_english/models/user_entity.dart'; | 5 | import 'package:wow_english/models/user_entity.dart'; |
7 | import 'package:wow_english/route/route.dart'; | 6 | import 'package:wow_english/route/route.dart'; |
8 | import 'package:wow_english/utils/sp_util.dart'; | 7 | import 'package:wow_english/utils/sp_util.dart'; |
@@ -10,6 +9,9 @@ import 'package:wow_english/utils/sp_util.dart'; | @@ -10,6 +9,9 @@ import 'package:wow_english/utils/sp_util.dart'; | ||
10 | import '../../utils/audio_player_util.dart'; | 9 | import '../../utils/audio_player_util.dart'; |
11 | 10 | ||
12 | class UserUtil { | 11 | class UserUtil { |
12 | + | ||
13 | + static const String _prefsKeyUserInfo = "key_user_info"; | ||
14 | + | ||
13 | static UserEntity? _userEntity; | 15 | static UserEntity? _userEntity; |
14 | 16 | ||
15 | static void saveUser(UserEntity? user) { | 17 | static void saveUser(UserEntity? user) { |
@@ -41,16 +43,16 @@ class UserUtil { | @@ -41,16 +43,16 @@ class UserUtil { | ||
41 | } | 43 | } |
42 | 44 | ||
43 | static void _saveUserJson(String userJson) { | 45 | static void _saveUserJson(String userJson) { |
44 | - SpUtil.getInstance().setData(SpConst.prefsKeyUserInfo, userJson); | 46 | + SpUtil.getInstance().setData(_prefsKeyUserInfo, userJson); |
45 | } | 47 | } |
46 | 48 | ||
47 | static String? _getUserJson() { | 49 | static String? _getUserJson() { |
48 | - return SpUtil.getInstance().get<String>(SpConst.prefsKeyUserInfo); | 50 | + return SpUtil.getInstance().get<String>(_prefsKeyUserInfo); |
49 | } | 51 | } |
50 | 52 | ||
51 | static void _clearUserData() { | 53 | static void _clearUserData() { |
52 | _userEntity = null; | 54 | _userEntity = null; |
53 | - SpUtil.getInstance().remove(SpConst.prefsKeyUserInfo); | 55 | + SpUtil.getInstance().remove(_prefsKeyUserInfo); |
54 | } | 56 | } |
55 | 57 | ||
56 | static void logout([bool showPasswordLoginPage = false]) { | 58 | static void logout([bool showPasswordLoginPage = false]) { |