Files
syncrow-app/lib/utils/helpers/cache_helper.dart
T
Mohammad Salameh 1d18210158 restructured the application
added .end files
switched to BLoC state-management
removed unnecessary helpers
initialized Scenes Page
2024-02-15 14:00:09 +03:00

32 lines
825 B
Dart

import 'package:shared_preferences/shared_preferences.dart';
class CacheHelper {
static late SharedPreferences sharedPreferences;
static init() async {
sharedPreferences = await SharedPreferences.getInstance();
}
static Object? getData({
required String key,
}) async {
return sharedPreferences.get(key);
}
static Future setData({
required String key,
required value,
}) async {
if (value is String) return await sharedPreferences.setString(key, value);
if (value is int) return await sharedPreferences.setInt(key, value);
if (value is bool) return await sharedPreferences.setBool(key, value);
return await sharedPreferences.setDouble(key, value);
}
static dynamic removeData({
required String key,
}) async {
return sharedPreferences.remove(key);
}
}