Flutter ListTile领先的图像和标题对齐

时间:2019-11-04 20:10:19

标签: listview flutter alignment

在标准ListTile中,是否可以将前导图像和标题对齐在顶部,并对齐?

10103;Baldwin, C;SFEN
10115;Wyatt, X;SFEN
10172;Forbes, I;SFEN
10175;Erickson, D;SFEN
10183;Chapman, O;SFEN
11399;Cordova, I;SYEN
11461;Wright, U;SYEN
11658;Kelly, P;SYEN
11714;Morton, A;SYEN
11788;Fuller, E;SYEN

https://api.flutter.dev/flutter/material/ListTile-class.html

1 个答案:

答案 0 :(得分:0)

我认为您应该考虑使用Row的{​​{3}}中所说的ListTile小部件,例如,应该使用Row来实现复杂的UI。 根据您的情况,您需要一个Row,属性为crossAxisAlignment: CrossAxisAlignment.start

Row(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: <Widget>[
      CircleAvatar(
        radius: 20,
        backgroundImage: AssetImage('assets/avatar1.jpg'),
      ),
      Expanded(
        child: Container(
          padding: EdgeInsets.only(left: 5),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              RichText(
                text: TextSpan(
                  style: DefaultTextStyle.of(context).style,
                  children: [
                    TextSpan(
                      text: 'hello :  ',
                      style: TextStyle(fontWeight: FontWeight.bold),
                    ),
                    TextSpan(
                      text:
                          'the comment comment the comment comment the comment comment comment comment the comment comment the comment comment',
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    ],
  ),