Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: CheckboxListTile remove default padding

I'm looking to remove this padding around my row of CheckboxListTiles, but haven't found any information on how to do this without making my own version of a checkbox.

enter image description here

Is there any way to (using the CheckboxListTile):

  1. Remove the (blue) left and right padding of the CheckboxListTile
  2. Increase the width of the text area (I've tried sizedbox, containers, etc with no luck)
like image 310
Michael Tolsma Avatar asked Feb 18 '20 13:02

Michael Tolsma


3 Answers

UPDATE: There is no need to use ListTitleTheme anymore. contentPadding is now one of CheckboxListTile's properties. We can now remove the default padding like this:

CheckboxListTile(
 contentPadding: EdgeInsets.zero,
)
like image 161
Uni Avatar answered Nov 20 '22 18:11

Uni


Try using the following code:

ListTileTheme(
  contentPadding: EdgeInsets.all(0),
  child: CheckboxListTile(
    secondary: const Icon(Icons.drive_eta),
    title: Text("Your message"),
    onChanged: (bool value) {},
    value: true,
  ),
),
like image 22
Lucas Vellido Avatar answered Nov 20 '22 16:11

Lucas Vellido


Add

ListTileTheme(
            contentPadding: EdgeInsets.all(0),
        

then

 ListTileTheme(
            contentPadding: EdgeInsets.all(0),
            child: CheckboxListTile(
              activeColor: CustomColors.purple,
              title: Text("title text"),
              value: true,
              onChanged: (newValue) {},
              controlAffinity:
                  ListTileControlAffinity.leading, //  <-- leading Checkbox
            ),
          ),
like image 3
Julio Avatar answered Nov 20 '22 18:11

Julio