Commit 4d8f38e5 authored by Hans Muller's avatar Hans Muller

Correct ListItem leading/trailing widget layout (#3820)

parent a6a3f2c3
...@@ -43,9 +43,7 @@ class ListItem extends StatelessWidget { ...@@ -43,9 +43,7 @@ class ListItem extends StatelessWidget {
this.enabled: true, this.enabled: true,
this.onTap, this.onTap,
this.onLongPress this.onLongPress
}) : super(key: key) { }) : super(key: key);
assert(isThreeLine ? subtitle != null : true);
}
/// A widget to display before the title. /// A widget to display before the title.
/// ///
...@@ -149,19 +147,15 @@ class ListItem extends StatelessWidget { ...@@ -149,19 +147,15 @@ class ListItem extends StatelessWidget {
else else
itemHeight = dense ? 76.0 : 88.0; itemHeight = dense ? 76.0 : 88.0;
double iconMarginTop = 0.0;
if (isThreeLine)
iconMarginTop = dense ? 8.0 : 16.0;
// Overall, the list item is a Row() with these children. // Overall, the list item is a Row() with these children.
final List<Widget> children = <Widget>[]; final List<Widget> children = <Widget>[];
if (leading != null) { if (leading != null) {
children.add(new Container( children.add(new Container(
margin: new EdgeInsets.only(right: 16.0, top: iconMarginTop), margin: const EdgeInsets.only(right: 16.0),
width: 40.0, width: 40.0,
child: new Align( child: new Align(
alignment: new FractionalOffset(0.0, isThreeLine ? 0.0 : 0.5), alignment: FractionalOffset.centerLeft,
child: leading child: leading
) )
)); ));
...@@ -173,7 +167,7 @@ class ListItem extends StatelessWidget { ...@@ -173,7 +167,7 @@ class ListItem extends StatelessWidget {
child: title ?? new Container() child: title ?? new Container()
); );
Widget center = primaryLine; Widget center = primaryLine;
if (isTwoLine || isThreeLine) { if (subtitle != null && (isTwoLine || isThreeLine)) {
center = new Column( center = new Column(
mainAxisAlignment: MainAxisAlignment.collapse, mainAxisAlignment: MainAxisAlignment.collapse,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
...@@ -193,9 +187,9 @@ class ListItem extends StatelessWidget { ...@@ -193,9 +187,9 @@ class ListItem extends StatelessWidget {
if (trailing != null) { if (trailing != null) {
children.add(new Container( children.add(new Container(
margin: new EdgeInsets.only(left: 16.0, top: iconMarginTop), margin: const EdgeInsets.only(left: 16.0),
child: new Align( child: new Align(
alignment: new FractionalOffset(1.0, isThreeLine ? 0.0 : 0.5), alignment: FractionalOffset.centerRight,
child: trailing child: trailing
) )
)); ));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment