作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
values('Date', ': ${DateFormat('MMM dd, yyyy, hh:mm a').format(DateTime.parse(date))}', false),
values('Description', ': $description', false),
],
),
),
Widget values(String title, String value, bool isAmount) {
return Row(
children: <Widget>[
Text(
title,
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey),
),
Spacer(),
Text(
value,
style: TextStyle(
color: isAmount ? Color(0xFF34B3C1) : Colors.black87,
),
),
Spacer(),
],
);
}
最佳答案
使用扩展后的和 flex 来实现,
Widget values(String title, String value, bool isAmount) {
return Row(
children: <Widget>[
Expanded(
flex: 3,
child: Text(
title,
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey),
),
),
Spacer(),
Expanded(
flex: 7,
child: Text(
value,
style: TextStyle(
color: isAmount ? Color(0xFF34B3C1) : Colors.black87,
),
),
),
Spacer(),
],
);
}
关于flutter - 在列小部件内的特定位置对齐行项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58948539/
我是一名优秀的程序员,十分优秀!