You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.5 KiB
Dart
53 lines
1.5 KiB
Dart
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 Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
|
|
|
static setUserId(String cookie) async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
prefs.setString(USER_ID, cookie) ?? "NA";
|
|
}
|
|
|
|
static Future<String> 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) ?? "NA";
|
|
}
|
|
|
|
static Future<String> 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) ?? "NA";
|
|
}
|
|
|
|
static Future<String> 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) ?? "NA";
|
|
}
|
|
|
|
static Future<String> getUserPassword() async {
|
|
SharedPreferences prefs = await _prefs;
|
|
return prefs.getString(PASSWORD) ?? "";
|
|
}
|
|
}
|