Reputation: 217
I'm new to Flutter and I found a pretty cool design of a todoapp on Dribble so I wanted to create the app. Here's the design :
I wonder how with the my callBack Function of my CheckBox I could change the color of the text part of the tile to this blue. My tile is currently a row containing a checkbox and a Container with the text in. So I would like to when i click on the checkbox, the background color of my container turns to blue. I dont' have a any idea how to do that. If you have some ideas please tell me.
Upvotes: 2
Views: 596
Reputation: 217
Well, I just needded to put this in the color property of my container knowing that isChecked is true when my checkbox is clicked.
child: Container(
height: 50,
decoration: BoxDecoration(
borderRadius : BorderRadius.circular(15),
color: widget.isChecked ? Color(0xFF2765f9) : Color(0xFF292E3C),
Upvotes: 0
Reputation: 574
Flutter apps work with app states, these states contain the information about the screens pushed by the app.
What you need to do is to update the state of your current widget, and change the values that set that background to X color.
Here you have multiple docs about state management: https://flutter.dev/docs/development/data-and-backend/state-mgmt/options, I really recommend for beginners to start with the setState method as is the easiest one.
Also, if you don't know how to manage states I will really recommend to follow the docs to understand how widget works and are build over flutter apps: https://flutter.dev/docs/development/ui/widgets-intro
Upvotes: 1