Search code examples
flutterflutter-animatedlist

Flutter AnimatedList - how to update an existing item?


AnimatedList has two methods, insert and delete for items in the list. https://api.flutter.dev/flutter/widgets/AnimatedList-class.html

In my case I have complex items, and their properties can change.

How would I update an existing item in an AnimatedList if a property changes without removing or inerting the whole item again?

Would it be a simple setState call?


Solution

  • Use the setState method for updating the list item builder. Reference

     setState(() {
                      items[index].checked = value!;
                    });