【发布时间】:2021-05-17 20:39:24
【问题描述】:
我正在尝试在 Row 中使用 MainAxixsAlignment(spaceBetween)。 这是我的代码
ListView.separated(
shrinkWrap: true,
separatorBuilder: (context, index) => Divider(
color: Colors.black,
indent: 20,
endIndent: 20,
),
itemCount: prayerTimes.length,
itemBuilder: (context, index) => Padding(
padding: EdgeInsets.all(8.0),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
prayerTimes[index].name,
style: TextStyle(
color: Colors.teal,
fontWeight: FontWeight.bold,
fontSize: 18.0),
),
Text(
prayerTimes[index].time,
style: TextStyle(color: Colors.teal, fontSize: 18.0),
),
Icon(
Icons.volume_up,
color: Colors.teal,
)
],
)),
),
)
如您所见,当第一行标题名称较大时,中间行中的时间未对齐。 如何使中间文本小部件与第一个和最后一个小部件对齐?
【问题讨论】:
-
它实际上按预期工作,您需要将行中的所有 3 个元素包装在
Expanded中,以便它们占用相等的空间。