0

I'm trying to make a Flutter screen that changes the icon (from unchecked to checked) when the ListTile is tapped. I've continued on from the first Flutter app tutorial, https://docs.flutter.dev/get-started/codelab which has something very similar that functions.

However, when I tap my ListTile the boolean changes values (as evidenced by my print() statement), but the icon stays the same, despite using setState(). I'm brand new to Flutter, could someone please point out what I'm doing wrong?

Edit: It looks like I needed to wrap after builder: in a StatefulBuilder... but now the question is how to address each check box individually, instead of all at once?

5
  • provide ready to run code Commented Sep 3, 2022 at 21:05
  • you should put your var checked = false outside your build Commented Sep 3, 2022 at 21:06
  • I think checked should be inside: moving it outside makes the bool apply to all 4 checkboxes, instead of each checkbox having its own. The icons still didn't update after doing so, either Commented Sep 3, 2022 at 21:30
  • Does this answer your question? Updating a widget from a List<Widget> in flutter? Commented Sep 4, 2022 at 8:08
  • give unique bool name to each check box like bool checked, checked1, checked2... = false; Commented Sep 4, 2022 at 16:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.