2022-11-23 10:56:29 +00:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
|
|
class PreferenceService {
|
|
|
|
PreferenceService._privateConstructor();
|
|
|
|
static final PreferenceService instance =
|
|
|
|
PreferenceService._privateConstructor();
|
|
|
|
|
|
|
|
late final SharedPreferences _prefs;
|
|
|
|
|
|
|
|
static const kHasShownCoachMarkKey = "has_shown_coach_mark";
|
2023-09-08 12:21:58 +00:00
|
|
|
static const kShouldShowLargeIconsKey = "should_show_large_icons";
|
2022-11-23 10:56:29 +00:00
|
|
|
|
|
|
|
Future<void> init() async {
|
|
|
|
_prefs = await SharedPreferences.getInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasShownCoachMark() {
|
|
|
|
if (_prefs.containsKey(kHasShownCoachMarkKey)) {
|
|
|
|
return _prefs.getBool(kHasShownCoachMarkKey)!;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> setHasShownCoachMark(bool value) {
|
|
|
|
return _prefs.setBool(kHasShownCoachMarkKey, value);
|
|
|
|
}
|
2023-09-08 12:21:58 +00:00
|
|
|
|
|
|
|
bool shouldShowLargeIcons() {
|
|
|
|
if (_prefs.containsKey(kShouldShowLargeIconsKey)) {
|
|
|
|
return _prefs.getBool(kShouldShowLargeIconsKey)!;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> setShowLargeIcons(bool value) {
|
|
|
|
return _prefs.setBool(kShouldShowLargeIconsKey, value);
|
|
|
|
}
|
2022-11-23 10:56:29 +00:00
|
|
|
}
|