flutter/lib/utils/storage.dart
2025-07-21 15:46:30 +08:00

37 lines
707 B
Dart

/// 封装get_storage缓存类
library;
import 'package:get_storage/get_storage.dart';
class Storage {
/// 读取缓存
/// * [key] 缓存标识
static read(String key) {
return GetStorage().read(key);
}
/// 写入缓存
/// * [key] 缓存标识
/// * [value] 存储值
static write(String key, value) {
GetStorage().write(key, value);
}
/// 是否有缓存数据
/// * [key] 缓存标识
static hasData(String key) {
return GetStorage().hasData(key);
}
/// 删除缓存
/// * [key] 缓存标识
static remove(key) {
GetStorage().remove(key);
}
/// 清空缓存
static clear() {
GetStorage().erase();
}
}