带有if语句的Flutter CrossAxisAlignment

时间:2019-08-22 14:17:54

标签: flutter dart

有时想将我的Expanded类与end对齐,有时甚至要与start对齐。如何将Expanded类与if语句对齐?

 new Expanded(
              child: new Column(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: <Widget>[
                  new Text(defaultUserName, style: Theme.of(ctx).textTheme.subhead),
                  new Container(
                    margin: const EdgeInsets.only(top: 10.0,right: 10.0),
                    child: new Text(txt),
                  ),
                ],
              ),
            ),

1 个答案:

答案 0 :(得分:4)

使用方式:

crossAxisAlignment: _alignEnd ? CrossAxisAlignment.end : CrossAxisAlignment.start,