Search code examples
flutterdartmaterial-uiflutter-material

Flutter Listen List Object When Any Item Value Change


i have an List item keeping bool values like that:
List<bool> isSelectedDiscountValue = [false, false];

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

that code return to me flutter the method listen is not defined for the type list error.

i was listened any int or string values but its not possible on list. i need listen this list cause when any value change i will some changes on ui. but i can't listen to list. how can i listen the list values?


Solution

  • Use ValueNotifier and ValueListenableBuilder