diff --git a/lib/service/settings_service.dart b/lib/service/settings_service.dart index cc7a0f6..e42173b 100644 --- a/lib/service/settings_service.dart +++ b/lib/service/settings_service.dart @@ -2,27 +2,28 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:smoke_cess_app/models/settings.dart'; import 'package:smoke_cess_app/service/json_service.dart'; -final Future _prefs = SharedPreferences.getInstance(); - //access group setting which was saved in local storage Future getGroup() { return getStringSetting('group'); } void setStringSetting(String settingKey, String settingValue) => - _prefs.then((pref) => pref.setString(settingKey, settingValue)); + SharedPreferences.getInstance() + .then((pref) => pref.setString(settingKey, settingValue)); Future getStringSetting(String settingKey) => - _prefs.then((pref) => pref.getString(settingKey)); + SharedPreferences.getInstance().then((pref) => pref.getString(settingKey)); void setIntSetting(String settingKey, int settingValue) => - _prefs.then((pref) => pref.setInt(settingKey, settingValue)); + SharedPreferences.getInstance() + .then((pref) => pref.setInt(settingKey, settingValue)); Future getIntSetting(String settingKey) => - _prefs.then((pref) => pref.getInt(settingKey)); + SharedPreferences.getInstance().then((pref) => pref.getInt(settingKey)); void setStringList(String settingKey, List list) => - _prefs.then((pref) => pref.setStringList(settingKey, list)); + SharedPreferences.getInstance() + .then((pref) => pref.setStringList(settingKey, list)); //Add other setters and getters if needed //other possible SharedPreferences Types: Int, Bool, Double, StringList