SharedPreferencesManager class

SharedPreferences 工具类

提供统一的本地存储操作接口,支持多种数据类型的存储和读取 采用单例模式,确保全局只有一个实例

Constructors

SharedPreferencesManager()
工厂构造函数,返回单例实例
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() Future<bool>
清空所有数据
containsKey(String key) Future<bool>
检查是否包含指定键
getBool(String key) Future<bool?>
读取布尔值
getDouble(String key) Future<double?>
读取双精度浮点数
getInt(String key) Future<int?>
读取整数
getKeys() Future<Set<String>>
获取所有键
getString(String key) Future<String?>
读取字符串
getStringList(String key) Future<List<String>?>
读取字符串列表
initialize() Future<void>
初始化 SharedPreferences
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(String key) Future<bool>
删除指定键的数据
setBool(String key, bool value) Future<bool>
存储布尔值
setDouble(String key, double value) Future<bool>
存储双精度浮点数
setInt(String key, int value) Future<bool>
存储整数
setString(String key, String value) Future<bool>
存储字符串
setStringList(String key, List<String> value) Future<bool>
存储字符串列表
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited