51

How to remove the space top and bottom from ListTile?

My Code is:

 child: Column(
    children: <Widget>[
      ListTile(
        contentPadding: EdgeInsets.only(left: 0.0, right: 0.0),
        title: Text(
          'Home',
          style: TextStyle(fontSize: 15.0),
        ),
      ),
      ListTile(
        contentPadding: EdgeInsets.only(left: 0.0, right: 0.0),
        title: Text(
          'Audio',
          style:
              TextStyle(fontSize: 15.0, color: Colors.black45),
        ),
      ),),

Screenshot:

Screenshot

1
  • IMHO ListTile is 3-lines by design. Just use Text without ListTile. Commented May 7 at 20:56

13 Answers 13

88

UPDATE

Now you can also use the following propertier:

  1. horizontalTitleGap - Between title and leading
  2. minVerticalPadding - Between title and subtitle
  3. minLeadingWidth - Minimum width of leading
  4. contentPadding - Internal padding

OLD

You can use the visualDensity property to reduce the space.

ListTile(
    visualDensity: VisualDensity(horizontal: 0, vertical: -4),
    title: Text("xyz")
);

The visualDensity value can be changed from -4.0 to 4.0. Lower the value, more compact the view.

P.S. This solution is similar to a different question

This question is about the top/bottom spacing. But the other question is about gap between leading and title

5
  • 3
    I'm not able to find this "visualDensity" in my ListTile widget properties!!!
    – Alex Roy
    Commented Aug 28, 2020 at 6:57
  • 1
    solved 50% space, still have 6-8 pixels gap between top of Listtile and content.
    – Kamlesh
    Commented Feb 28, 2021 at 9:30
  • @Kamlesh you can create a custom list tile , if you need more flexibility
    – reverie_ss
    Commented Mar 2, 2021 at 11:44
  • visualDensity can reduce height between ListTiles
    – Rudy Rudy
    Commented Jun 5, 2021 at 8:30
  • 1
    minVerticalPadding worked perfectly for me. Commented Aug 19, 2021 at 13:09
50

In your code put property dense: true inside the list tile

       ListTile(
                dense:true,
                contentPadding: EdgeInsets.only(left: 0.0, right: 0.0),
                title: Text(
                  'Home',
                  style: TextStyle(fontSize: 15.0),
                ),
              ),

Hope it helps!

3
  • 11
    It only removes horizontal padding, not vertical ones. Commented Jul 31, 2020 at 4:16
  • "dense: true" alone did decrement the vertical spacing. but content padding didn't work for vertical spacing issue Commented Sep 9, 2020 at 12:01
  • Adding fontSize along with other settings did help to reduce the top padding
    – Stan
    Commented Nov 27, 2022 at 11:08
24
ListTile(
    dense: true,
    contentPadding: EdgeInsets.symmetric(horizontal: 0.0, vertical: 0.0),
    visualDensity: VisualDensity(horizontal: 0, vertical: -4),
);

Above solution worked for me. I hope, this will also help you. Thanks for asking this question.

14

That worked for me in ListTile:

visualDensity: VisualDensity(horizontal: 0, vertical: -4)
9

With ListTile it is not possible. Some modifications are possible with the help of ListTileTheme like color and there is also the option of modifying padding but only work for left and right padding. So better is to create your own custom tile as @santosh showed in his answer. You can also use SizedBox but it can result in tragic output.

1
5

Try this

              child: Column(
                children: <Widget>[
                    Text(
                      'Home',
                      style: TextStyle(fontSize: 15.0),
                    ),
                    Text(
                      'Audio',
                      style:
                          TextStyle(fontSize: 15.0, color: Colors.black45),
                    ),
                 ),)
3

this is worked for me

ListTile(
  dense:true,
  minVerticalPadding: 0,
  contentPadding: EdgeInsets.zero,
  visualDensity: VisualDensity(horizontal: 0, vertical: 4),
        );

now I have no padding at all

3
ListTile(
  minVerticalPadding: 0, // else 2px still present
  dense: true, // else 2px still present
  visualDensity: VisualDensity.compact, // Else theme will be use
  contentPadding: const EdgeInsets.zero, // Or what do you want, you will have now the exact amount of padding as expected
),
1

Let's try with shorter way:

ListTile(
          contentPadding: EdgeInsets.zero,
          dense: true,
          title: Text('label'),
        );
1
  • contentPadding helped me to remove left right space
    – Mrinmoy
    Commented Jun 24, 2021 at 14:51
1
ListTile(
  dense: true,
  visualDensity: VisualDensity(horizontal: 0, vertical: -4),
  contentPadding: EdgeInsets.only(left: 0.0,right: 0.0, top: 0.0),
  title:  LabelText(
    labelText: "Cara",
    fontSize: 14,
    fontWeight: FontWeight.w600,
    color: AppColor.txtColor,
    textAlign: TextAlign.center
  ),
  subtitle:  LabelText(
    labelText: "Patient #1",
    fontSize: 12,
    fontWeight: FontWeight.normal,
    color: AppColor.inactive,
    textAlign: TextAlign.center
  ),
),
1
  • 1
    Your answer could be improved by adding more information on what the code does and how it helps the OP.
    – Tyler2P
    Commented Mar 5, 2023 at 19:20
0

For me Padding widget worked in place of ListTile.padding variable can be updated as per your requirements for a ListItem.

Padding(
        padding: const EdgeInsets.only(left : 8.0 , right 8.0),
        child: Text("List Item Text",
            style: Theme.of(context).textTheme.body1))
0

I have tried one by one and with all possible combinations using the four easily possible ways, these are using:

  • contentPadding: EdgeInsets.zero
  • visualDensity: VisualDensity.compact
  • minVerticalPadding: 0
  • dense: true

I came to the conclusion that the only thing that should be used if you want to make a ListTile as small vertically as possible, is just using visualDensity in this way.

ListTile(
  visualDensity: const VisualDensity(horizontal: 0, vertical: -4),
  ...
)
1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jun 4 at 8:13
-1

None of the solutions above will work (for now). Your best bet is to use a TextButton and include a Row as the child

Not the answer you're looking for? Browse other questions tagged or ask your own question.