forked from eatvio/eatvio_app
fix: analyzer and token storage
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'locator_service.dart';
|
||||
|
||||
abstract class TokenStorage {
|
||||
static bool haveTokenInStorage() {
|
||||
static Future<bool> haveTokenInStorage() async {
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
try {
|
||||
if (sl<SharedPreferences>().getString('token') == null) {
|
||||
if (sharedPreferences.getString('token') == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -14,19 +14,27 @@ abstract class TokenStorage {
|
||||
}
|
||||
}
|
||||
|
||||
static String? getTokenFromStorage() => sl<SharedPreferences>().getString('token');
|
||||
|
||||
static Future<void> saveTokenInStorage(String token) async {
|
||||
await sl<SharedPreferences>().setString('token', token);
|
||||
static Future<String?> getTokenFromStorage() async {
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
return sharedPreferences.getString('token');
|
||||
}
|
||||
|
||||
static Future<void> removeTokenInStorage() async => (await sl<SharedPreferences>().remove('token'));
|
||||
static Future<void> saveTokenInStorage(String token) async {
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
await sharedPreferences.setString('token', token);
|
||||
}
|
||||
|
||||
static Future<void> removeTokenInStorage() async {
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
await sharedPreferences.remove('token');
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SocketIdStorage {
|
||||
static bool haveSocketIdInStorage() {
|
||||
static Future<bool> haveSocketIdInStorage() async {
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
try {
|
||||
if (sl<SharedPreferences>().getString('socketId') == null) {
|
||||
if (sharedPreferences.getString('socketId') == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -36,11 +44,18 @@ abstract class SocketIdStorage {
|
||||
}
|
||||
}
|
||||
|
||||
static String? getSocketIdFromStorage() => sl<SharedPreferences>().getString('socketId');
|
||||
|
||||
static Future<void> saveSocketIdInStorage(String socketId) async {
|
||||
await sl<SharedPreferences>().setString('socketId', socketId);
|
||||
static Future<String?> getSocketIdFromStorage() async {
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
return sharedPreferences.getString('socketId');
|
||||
}
|
||||
|
||||
static Future<void> removeSocketIdInStorage() async => (await sl<SharedPreferences>().remove('socketId'));
|
||||
static Future<void> saveSocketIdInStorage(String socketId) async {
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
await sharedPreferences.setString('socketId', socketId);
|
||||
}
|
||||
|
||||
static Future<void> removeSocketIdInStorage() async {
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
await sharedPreferences.remove('socketId');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user