feat:参照研听的基础工程
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
const storageThemeMode = 'theme_mode';
|
||||
const storagePrivacyAgreed = 'privacy_agreed'; // Android 首启隐私同意(设备采集门控)
|
||||
const storageIosStartupSeen = 'ios_startup_seen'; // iOS 首次启动页已展示
|
||||
const storageJinzhiHoldings = 'jinzhi_holdings';
|
||||
const storageJinzhiAmountHidden = 'jinzhi_amount_hidden';
|
||||
const storageJinzhiRecycleDiscounts = 'jinzhi_recycle_discounts';
|
||||
const storageJinzhiPurityPresets = 'jinzhi_purity_presets';
|
||||
const storageJinzhiPriceColorMode = 'jinzhi_price_color_mode';
|
||||
const storageJinzhiMockLoggedIn = 'jinzhi_mock_logged_in';
|
||||
|
||||
// 设备/广告标识。由各自的 SDK/ATT 流程写入,DeviceHeaderService 读出注入
|
||||
// header;未写入则为空、注入时被过滤。
|
||||
const storageDeviceToken = 'device_token'; // 推送 token
|
||||
const storageAndroidId = 'android_id';
|
||||
const storageAndroidOaid = 'android_oaid';
|
||||
const storageAndroidImei = 'android_imei';
|
||||
const storageAndroidMac = 'android_mac';
|
||||
const storageIosIdfa = 'ios_idfa';
|
||||
const storageIosPaid = 'ios_paid';
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class StorageService {
|
||||
StorageService._(this._prefs);
|
||||
final SharedPreferences _prefs;
|
||||
static StorageService? _instance;
|
||||
static StorageService get to => _instance!;
|
||||
|
||||
static Future<StorageService> get instance async {
|
||||
if (_instance != null) return _instance!;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_instance = StorageService._(prefs);
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
bool getBool(String key, {bool def = false}) => _prefs.getBool(key) ?? def;
|
||||
Future<void> setBool(String key, bool v) => _prefs.setBool(key, v);
|
||||
String? getString(String key) => _prefs.getString(key);
|
||||
Future<void> setString(String key, String v) => _prefs.setString(key, v);
|
||||
}
|
||||
Reference in New Issue
Block a user