i have a compromise solution below which do not satisfy me .
final int padding=10; //the padding you wanna set.
ListTile(
leading: Icon(icon),
title: Container(
height: 30,
child: Stack(
alignment: Alignment.centerLeft,
overflow: Overflow.visible,
children: <Widget>[
Positioned(
child: title,
left: padding-35,
),
],
),
),
);
yes. you can use the negative margin. which definitely works. but it is not perfect .so could anyone offer a better solution ?
========= Additional ===========
i see some answer below .but it seems you do not get my points.
the default padding between leading and title from Flutter ListTile is too large for me. i wanna adjust the padding by myself . and just wrapping the title with Padding widget can not achieve the goal .
========= A better solution i found ===========
final int padding = 10; //the padding you wanna set.
ListTile(
leading: Icon(icon),
title: Container(
transform: Matrix4.translationValues(padding - 35, 0.0, 0.0),
child: title,
),
);
Use Padding widget like :
ListTile(
leading: Icon(Icons.location_on),
title: Padding(
// change left :
padding: const EdgeInsets.only(left: 30),
child: Text('hello world'),
),
),
You can add padding to your title widget for this.
Replace your code with:
final double padding=10; //the padding you wanna set.
ListTile(
leading: Icon(icon),
title: Padding(
padding: const EdgeInsets.all(padding),
child:Container(
height: 30,
child: Stack(
alignment: Alignment.centerLeft,
overflow: Overflow.visible,
children: <Widget>[
Positioned(
child: title,
left: padding-35,
),
],
),
),
),
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.