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/