26 lines
902 B
Dart
26 lines
902 B
Dart
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class SettingsService {
|
|
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
|
|
|
SettingsService() {
|
|
setIntSetting('workout_duration_minutes', 5);
|
|
}
|
|
|
|
void setStringSetting(String settingKey, String settingValue) =>
|
|
_prefs.then((pref) => pref.setString(settingKey, settingValue));
|
|
|
|
Future<String?> getStringSetting(String settingKey) =>
|
|
_prefs.then((pref) => pref.getString(settingKey));
|
|
|
|
void setIntSetting(String settingKey, int settingValue) =>
|
|
_prefs.then((pref) => pref.setInt(settingKey, settingValue));
|
|
|
|
Future<int?> getIntSetting(String settingKey) =>
|
|
_prefs.then((pref) => pref.getInt(settingKey));
|
|
|
|
//Add other setters and getters if needed
|
|
//other possible SharedPreferences Types: Int, Bool, Double, StringList
|
|
//see https://pub.dev/packages/shared_preferences
|
|
}
|