flutter checkbox checked on container clicked

Viewed 520

When I click on the checkbox it checked. What I want is even if I click on the entire container wrapping the checkbox, it checked also. But I can't seem to find a way.

Here is my code:

InkWell(
   onTap: () {},
   child: Container(
      child: Checkbox(
         activeColor: Color(0xFF2481CF),
         shape: CircleBorder(
            side: BorderSide(
               color: Colors.grey
            )
         ),
         checkColor: Colors.white,
         value: contactList[index].select,
         onChanged: (value) {
            var query = mains.objectbox.boxContact.query(ContactModel_.email.equals(contactList[index].email.toString())).build();
            setState(() {
               ...
            })
...

Is there any solution?

1 Answers

You can update the Checkbox value when it was tapped - which I see you already have an InkWell wrapping the Checkbox.

Assuming that contactList[index].select contains a bool, you can do something similar to this.

Inkwell(
  onTap: () {
     setState((){
       contactList[index].select = !contactList[index].select;
     });
  },
  ...
)
Related