任何项目值更改时的Flutter侦听列表对象



我有一个List项,它保存的布尔值如下:
List<bool> isSelectedDiscountValue = [false, false];

isSelectedDiscountValue.listen((selectedIndex)async {
await _setValues(selectedIndex);

代码返回给我flutter没有为类型列表错误定义方法listen。

我听过任何int或string值,但在列表中不可能。我需要听这个列表,因为当任何值更改时,我都会对ui进行一些更改。但我听不进去列表。我如何收听列表值?

Use ValueNotifier and ValueListenableBuilder

最新更新