user2570135
user2570135

Reputation: 2989

Flutter : how to left aligned a checkbox

I am adding a check box and list title to my app. However, these item are not left align with the other widgets. How can I align it with the other widgets

here is a picture

enter image description here

Upvotes: 42

Views: 28788

Answers (2)

Frederic Blanc
Frederic Blanc

Reputation: 71

Maybe a bit late but CheckboxListTile class has a contentPadding property which is set to horizontal 16 padding by default. Adding this line made the trick for me:

contentPadding: EdgeInsets.symmetric(horizontal: 0)

Upvotes: 7

Darshan
Darshan

Reputation: 11669

You can use CheckboxListTile widget which has property called controlAffinity. Setting it to leading will make the checkbox left aligned. Below is sample working code:

CheckboxListTile(
  controlAffinity: ListTileControlAffinity.leading,
  title: Text('I agree to the Terms and Conditions'),
  value: monVal,
  onChanged: (bool value) {
    setState(() {
      monVal = value;
    });
  },
)

And the output is:

enter image description here

Upvotes: 127

Related Questions