SelectedDataProvider<T> class

管理已选择数据的类

该类允许单选和多选模式,支持数据的添加、移除和更新,并通过监听器通知数据变化。

T 是选中数据的类型。

Mixed-in types

Constructors

SelectedDataProvider({bool equalPredict(T selected, T data)?, bool unique = true, bool single = false})
构造函数,初始化选中数据的比较器、单选和唯一性标志

Properties

data List<T>
获取已选的数据(返回一个不可修改的列表)
no setter
equalPredict bool Function(T selected, T data)
用于比较选中数据和其他数据是否相同的函数
final
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
是否允许单选(即只允许选中一个数据)
final
unique bool
是否确保选中的数据集合唯一
final

Methods

add(T data, {bool removeWhenExist = false}) → void
如果数据不存在,则将数据添加到已选数据中
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
override
contains(T? data) bool
判断是否包含指定的数据
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).
override
find(T? data) → T?
查找已选数据中与指定数据相同的数据
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyDataChanged() → void
手动触发数据变化通知
notifyListeners() → void
Call all the registered listeners.
inherited
remove(T data) → void
移除指定的数据
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
removeWhere(bool test(T element)) → void
根据条件移除已选数据,并通知刷新
toString() String
A string representation of this object.
inherited
update(T data) → void
更新已选中的数据项
updateAll(Iterable<T> data) → void
更新所有已选的数据

Operators

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