GlobalState<T> class

全局的状态 自带本地缓存 通过 key 创建的 GlobalState 实例是单例的 通过 setValue 方法设置的值会自动保存到本地 通过 listen 方法监听数据变化,lifecycleOwner 参数不为空时,会在 BaseViewStatedispose 方法中自动移除监听,这里需要注意调用时机需要在 BaseViewState 的 initState 方法之后 即 其子类的 super.initState(); 之后调用。 通过 removeObserver lifecycleOwner 参数为空时需要使用这主动移除监听。 通过 value 获取当前值

Constructors

GlobalState.new(String key, T defaultValue, {Parser<T>? parser, Serializer<T>? serializer})
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
key String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
获取当前值
no setter

Methods

listen(Observer<T> observer, {BaseViewState<StatefulWidget, ViewModel>? lifecycleOwner}) → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeObserver(Observer<T> observer) → void
setValue(T newData) → void
设置新的值
toString() String
A string representation of this object.
override

Operators

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