【发布时间】:2023-01-17 21:37:32
【问题描述】:
我似乎无法弄清楚如何将我的 CircleAvatar 居中放置在我的 ListTile 的尾部组件中。这是我的代码:
static Widget buildRecordCard(MyCard card, BuildContext context) {
var dateFormat = DateFormat('MM/dd/yyyy');
return Column(
children: [
ListTile(
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
tileColor: Colors.white,
title: Text(
"Score: " + card.score!,
style: const TextStyle(fontSize: 38),
),
subtitle: Column(children: [
const Align(
alignment: Alignment.centerLeft,
child: Text(
"Personal Record",
style: TextStyle(fontSize: 22),
),
),
const SizedBox(height: 6),
Align(
alignment: Alignment.centerLeft,
child: Text(
dateFormat.format(card.createdOn.toDate()),
style: const TextStyle(fontSize: 18),
),
),
const SizedBox(height: 6),
]),
trailing: Container(
constraints: const BoxConstraints(minWidth: 70.0, maxWidth: 80),
height: double.infinity,
child: CircleAvatar(
radius: 35,
backgroundColor: Colors.transparent,
child: Image.asset("assets/" + card.subCategory + ".png")),
)),
const SizedBox(height: 18),
],
);
}
我还尝试将我的 CircleAvatar 包裹在一个 SizedBox 和一个带有 mainAxisAlignment: MainAxisAlignment.center 的 Column 中,它产生了相同的输出。
【问题讨论】:
标签: flutter containers center listtile