SpUtils class

sp存储工具类

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

clear() → Future<bool>
清除sp
getBool(String key, {bool defValue = false}) → bool
get bool. 获取sp中key的布尔值
getDouble(String key, {double defValue = 0.0}) → double
get double. 获取sp中key的double值
getInt(String key, {int defValue = 0}) → int
get int. 获取sp中key的int值
getKeys() → Set<String>
获取sp中所有的key
getListT<T>(String key, T fromJsonT(dynamic json)) → List<T>?
获取sp中key的对象值
getMapListT<K, T>(String key, T fromJsonT(dynamic json)) → Map<K, List<T>?>?
获取sp中key的Map对象值
getMapT<K, T>(String key, T fromJsonT(dynamic json)) → Map<K, T?>?
获取sp中key的Map对象值
getString(String key, {String? defValue}) → String?
get string. 获取sp中key的字符串
getStringList(String key, {List<String>? defValue}) → List<String>?
get string list. 获取sp中key的list
getStringMap(String key) → Map?
获取sp中key的map值
getT<T>(String key, T fromJsonT(dynamic json)) → T?
获取sp中key的对象值
hasKey(String key) → bool
判断是否存在key的数据
init() → Future<SharedPreferences>
putBool(String key, bool value) → Future<bool>
put bool. 存储sp中key的布尔值
putDouble(String key, double value) → Future<bool>
put double. 存储sp中key的double值
putInt(String key, int value) → Future<bool>
put int. 存储sp中key的int值
putListT<T>(String key, List<T>? list, Map<String, dynamic> toJsonT(T value)) → Future<bool>
存储sp中key的对象值
putMapListT<K, T>(String key, Map<K, List<T>?> t, Map<String, dynamic> toJsonT(T value)) → Future<bool>
存储sp中key的Map对象值
putMapT<K, T>(String key, Map<K, T> t, Map<String, dynamic> toJsonT(T value)) → Future<bool>
存储sp中key的Map对象值
putString(String key, String value) → Future<bool>
put string. 存储sp中key的字符串
putStringList(String key, List<String> value) → Future<bool>
put string list. 存储sp中key的list
putStringMap(String key, Map value) → Future<bool>
存储sp中key的map值
putT<T>(String key, T t, Map<String, dynamic> toJsonT(T value)) → Future<bool>
存储sp中key的对象值
remove(String key) → Future<bool>
移除sp中key的值