import 'dart:async'; import 'package:shared_preferences/shared_preferences.dart'; class SharedPrefManager { static String USER_ID = "user.id"; static String USER_TOKEN = "user.token"; static String USER_NAME = "user.name"; static String PASSWORD = "user.password"; static String REFRESH_TOKEN = "user.refresh.token"; static String DATA = "data"; static final Future _prefs = SharedPreferences.getInstance(); static setUserId(String cookie) async { final prefs = await SharedPreferences.getInstance(); prefs.setString(USER_ID, cookie) ; } static Future getUserId() async { SharedPreferences prefs = await _prefs; return prefs.getString(USER_ID) ?? ""; } static setUserToken(String cookie) async { final prefs = await SharedPreferences.getInstance(); prefs.setString(USER_TOKEN, cookie) ; } static Future getUserToken() async { SharedPreferences prefs = await _prefs; return prefs.getString(USER_TOKEN) ?? ""; } static setPhoneOrEmail(String cookie) async { final prefs = await SharedPreferences.getInstance(); prefs.setString(USER_NAME, cookie) ; } static Future getPhoneOrEmail() async { SharedPreferences prefs = await _prefs; return prefs.getString(USER_NAME) ?? ""; } static setUserPassword(String cookie) async { final prefs = await SharedPreferences.getInstance(); prefs.setString(PASSWORD, cookie) ; } static Future getUserPassword() async { SharedPreferences prefs = await _prefs; return prefs.getString(PASSWORD) ?? ""; } static setRefreshToken(String cookie) async { final prefs = await SharedPreferences.getInstance(); prefs.setString(REFRESH_TOKEN, cookie) ; } static Future getRefreshToken() async { SharedPreferences prefs = await _prefs; return prefs.getString(REFRESH_TOKEN) ?? ""; } static setData(String cookie) async { final prefs = await SharedPreferences.getInstance(); prefs.setString(DATA, cookie); } static Future getData() async { SharedPreferences prefs = await _prefs; return prefs.getString(DATA) ?? ""; } }