import 'package:shared_preferences/shared_preferences.dart'; class SpUtil { static Future _getInstance() { return SharedPreferences.getInstance(); } static Future contains(String key) async { SharedPreferences sp = await _getInstance(); return sp.containsKey(key); } static Future remove(String key) async { SharedPreferences sp = await _getInstance(); return sp.remove(key); } static Future setInt(String key, int value) async { SharedPreferences sp = await _getInstance(); return sp.setInt(key, value); } static Future setDouble(String key, double value) async { SharedPreferences sp = await _getInstance(); return sp.setDouble(key, value); } static Future setBool(String key, bool value) async { SharedPreferences sp = await _getInstance(); return sp.setBool(key, value); } static Future setString(String key, String value) async { SharedPreferences sp = await _getInstance(); return sp.setString(key, value); } static Future setStringList(String key, List value) async { SharedPreferences sp = await _getInstance(); return sp.setStringList(key, value); } static Future getInt(String key, {int defValue = 0}) async { SharedPreferences sp = await _getInstance(); return sp.getInt(key) ?? defValue; } static Future getDouble(String key, {double defValue = 0.0}) async { SharedPreferences sp = await _getInstance(); return sp.getDouble(key) ?? defValue; } static Future getBool(String key, {bool defValue = false}) async { SharedPreferences sp = await _getInstance(); return sp.getBool(key) ?? defValue; } static Future getString(String key, {String defValue = ""}) async { SharedPreferences sp = await _getInstance(); return sp.getString(key) ?? defValue; } static Future> getStringList(String key) async { SharedPreferences sp = await _getInstance(); return sp.getStringList(key) ?? []; } static Future getEnableDelayShot() { return getBool("delayShot", defValue: false); } static Future setEnabelDelayShot(bool bo) { return setBool("delayShot", bo); } static Future getDelayShotTime() { return getInt("delayShotTime", defValue: 2); } static Future setDelayShotTime(int value) { return setInt("delayShotTime", value); } static Future getUserId() { return getString("userId", defValue: ""); } static Future setUserId(String userName) { return setString("userId", userName); } static Future getUserName() { return getString("userName", defValue: ""); } static Future setUserName(String userName) { return setString("userName", userName); } static Future getToken() { return getString("token", defValue: ""); } static Future setToken(String token) { return setString("token", token); } static Future getSelectedPatientId() { return getInt("selectedPatientId", defValue: -1); } static Future setSelectedPatientId(int id) { return setInt("selectedPatientId", id); } static Future isAppStartAgreementAgreed() { return getBool("appStartAgreementAgreed", defValue: false); } static Future setAppStartAgreementAgreed(bool bo) { return setBool("appStartAgreementAgreed", bo); } static Future hasStoragePermissionRequested() { return getBool("storagePermissionRequested", defValue: false); } static Future setStoragePermissionRequested(bool bo) { return setBool("storagePermissionRequested", bo); } static Future hasLocationPermissionRequested() { return getBool("locationPermissionRequested", defValue: false); } static Future setLocationPermissionRequested(bool bo) { return setBool("locationPermissionRequested", bo); } }