ObservableField<T> class

订阅字段 在 ValueNotifier 的基础上加上了可传空 @author sunlunchang

泛型类 ObservableField,继承自 ReadObservableField 提供了设置值的方法,可触发监听器

Inheritance

Constructors

ObservableField({T? value, bool single = false})
构造函数,初始化 ObservableField 实例 value 字段的初始值,默认为 null super.single 继承父类的 single 属性

Properties

hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
single bool
finalinherited
value → T?
获取字段的值
no setterinherited

Methods

addListener(VoidCallback listener) → void
重写 addListener 方法,用于添加监听器 如果已经有监听器且 single 为 true,则不添加新的监听器
inherited
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
重写 notifyListeners 方法,用于通知所有监听器
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
setValue(T? newValue) → void
设置字段的值 如果新值与旧值相同,则不做任何操作 否则更新值并通知所有监听器
setValueForcedNotify(T? value) → void
强制通知监听器 如果当前值与传入的值相同,直接通知监听器 否则调用 setValue 方法设置新值并通知监听器
toString() String
A string representation of this object.
inherited

Operators

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