mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-17 02:25:16 +00:00
initialized Application theme
This commit is contained in:
31
lib/utils/helpers/cache_helper.dart
Normal file
31
lib/utils/helpers/cache_helper.dart
Normal file
@ -0,0 +1,31 @@
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user