38

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

bad_coder
  • 11,289
  • 20
  • 44
  • 72
David Saan
  • 383
  • 1
  • 3
  • 4

12 Answers12

77

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

reverie_ss
  • 2,396
  • 23
  • 30
46

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!

Brinda Rathod
  • 2,693
  • 1
  • 20
  • 32
15
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.

Kamlesh
  • 5,233
  • 39
  • 50
10

That worked for me in ListTile:

visualDensity: VisualDensity(horizontal: 0, vertical: -4)
guenter47
  • 457
  • 5
  • 13
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.

Yashwardhan Pauranik
  • 5,370
  • 5
  • 42
  • 65
Chetan Pawar
  • 404
  • 3
  • 4
5

Try this

              child: Column(
                children: <Widget>[
                    Text(
                      'Home',
                      style: TextStyle(fontSize: 15.0),
                    ),
                    Text(
                      'Audio',
                      style:
                          TextStyle(fontSize: 15.0, color: Colors.black45),
                    ),
                 ),)
Santosh Anand
  • 1,230
  • 8
  • 13
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

1

Let's try with shorter way:

ListTile(
          contentPadding: EdgeInsets.zero,
          dense: true,
          title: Text('label'),
        );
DungPhan
  • 356
  • 3
  • 5
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))
Rakesh Verma
  • 766
  • 6
  • 14
0
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
  ),
),
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
  • 1
    Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P Mar 05 '23 at 19:20
0
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
),
Eng
  • 1,617
  • 2
  • 12
  • 25
-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

Lightwaxx
  • 625
  • 1
  • 8
  • 18