SpUtil class

SharedPreferences Util.

Constructors

SpUtil()

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 Properties

isInitialized → bool
是否已完成初始化,可用于可选依赖场景的安全探测。
no setter

Static Methods

clear() → Future<bool>
clear.
getBool(String key, {bool defValue = false}) → bool
get bool.
getDouble(String key, {double defValue = 0.0}) → double
get double.
getDynamic(String key, {required Object defValue}) → dynamic
get dynamic.
getInt(String key, {int defValue = 0}) → int
get int.
getKeys() → Set<String>
get keys.
getObj<T>(String key, T f(Map<String, dynamic> v), {required T defValue}) → T
get obj.
getObject(String key) → Map<String, dynamic>
get object.
getObjectList(String key) → List<Map<String, dynamic>>
get object list.
getObjList<T>(String key, T f(Map<String, dynamic> v)) → List<T>
get obj list.
getString(String key, {String defValue = ''}) → String
get string.
getStringList(String key, {List<String> defValue = const []}) → List<String>
get string list.
hasKey(String key) → bool
have key.
init() → Future<void>
putBool(String key, bool value) → Future<bool>
put bool.
putDouble(String key, double value) → Future<bool>
put double.
putInt(String key, int value) → Future<bool>
put int.
putObject(String key, Object value) → Future<bool>
put object.
putObjectList(String key, List list) → Future<bool>
put object list.
putString(String key, String value) → Future<bool>
put string.
putStringList(String key, List<String> value) → Future<bool>
put string list.
remove(String key) → Future<bool>
remove.
snapshot() → Map<String, Object?>
Returns the current SharedPreferences entries without emitting read logs.