是否存在实现ChangeNotifier的List类?基本上,如果将任何内容添加到列表中或重新排列了列表,它将调用notifyListeners?
答案 0 :(得分:1)
不。但这是一个:
class ChangeNotifierList<T> with ListMixin<T>, ChangeNotifier {
ChangeNotifierList(this._internalList);
final List<T> _internalList;
@override
int get length => _internalList.length;
@override
T operator [](int index) {
return _internalList[index];
}
@override
void operator []=(int index, T value) {
_internalList[index] = value;
notifyListeners();
}
@override
set length(int newLength) {
_internalList.length = newLength;
notifyListeners();
}
}