Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove padding from ListTile between leading and title

Tags:

flutter

dart

I need to remove some padding between leading Widget and title Widget in a ListTile. It has too much blank spaces. Is there a way to do that? The code that I am using for that is this:

ListTile _getActionMenu(String text, IconData icon, Function() onTap) {   return new ListTile(     leading: new Icon(icon),     title: new Text(text),     onTap: onTap,   ); } 
like image 838
Joseph Arriaza Avatar asked Jan 11 '19 21:01

Joseph Arriaza


People also ask

How do you reduce the space between leading and title in ListTile?

As Dinesh has pointed out here, ListTile has received a minLeadingWidth property. Default value is 40 , so to reduce space between leading and title by x pass minLeadingWidth: 40 - x .

How do I remove default padding from ListTile?

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.


1 Answers

EDIT: After Flutter 2.0 upgrade

As Dinesh has pointed out here, ListTile has received a minLeadingWidth property.

Default value is 40, so to reduce space between leading and title by x pass minLeadingWidth: 40 - x.


Align results will depend on text and tile width.

Use Transform.translate for consistent results.

ListTile(   leading: Icon(icon),   title: Transform.translate(     offset: Offset(-16, 0),     child: Text('Some text'),   ), ); 
like image 198
Rustem Kakimov Avatar answered Oct 01 '22 08:10

Rustem Kakimov