File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ import 'package:shared_preferences/shared_preferences.dart' ;
2
+
3
+ class PrefManager {
4
+ saveThemeIndex (int themeIndex) async {
5
+ final SharedPreferences prefs = await SharedPreferences .getInstance ();
6
+ await prefs.setInt ("themeIndex" , themeIndex);
7
+ }
8
+
9
+ Future <int > getThemeIndex () async {
10
+ final SharedPreferences prefs = await SharedPreferences .getInstance ();
11
+ final themeIndex = prefs.getInt ("themeIndex" );
12
+ if (themeIndex != null ) {
13
+ return themeIndex;
14
+ } else
15
+ return 0 ;
16
+ }
17
+
18
+ saveAccentIndex (int accentIndex) async {
19
+ final SharedPreferences prefs = await SharedPreferences .getInstance ();
20
+ await prefs.setInt ("accentIndex" , accentIndex);
21
+ }
22
+
23
+ Future <int > getAccentIndex () async {
24
+ final SharedPreferences prefs = await SharedPreferences .getInstance ();
25
+ final accentIndex = prefs.getInt ("accentIndex" );
26
+ if (accentIndex != null ) {
27
+ return accentIndex;
28
+ } else
29
+ return 0 ;
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments