Skip to content

Commit ad63dd0

Browse files
shared Prefs added
1 parent 0654e8e commit ad63dd0

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/utils/prefs_manager.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
}

0 commit comments

Comments
 (0)