Card、Container根据子View宽度自动适应宽度

Posted by アライさん on 2019年11月28日

如Card内嵌Text,根据Text文字长度自动调整宽度。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Flex(
crossAxisAlignment: CrossAxisAlignment.start,
direction: Axis.vertical,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Card(
elevation: 0.8,
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)),
),
child: Padding(
padding: EdgeInsets.fromLTRB(12.0, 12.0, 12.0, 12.0),
child: Text(
"我是单条rss的标题我是单条rss的标题我是单条rss的标题我是单条rss的标题我是单条rss的标题",
textAlign: TextAlign.left,
softWrap: true,
),
),
],
),