Flutter ListTile - 垂直对齐所有项目到中心

Flutter ListTile - Vertical align all items to center

我想将 ListTile 中的所有内容(标题、副标题、前导、尾随等)垂直居中对齐。最好的方法是什么?

const Padding(
    padding: EdgeInsets.fromLTRB(0, 20, 0, 20),
    child: Card(
      child: ListTile(
        leading: FlutterLogo(size: 55),
        title: Text('Overview'),
        subtitle: Text(
          '250.956.261',
        ),
        trailing: Icon(
          Icons.arrow_right_outlined,
          size: 30,
        ),
        isThreeLine: true,
      ),
    ),
),

您可以使用下面的替代代码来获得您想要的

         Padding(
          padding: const EdgeInsets.fromLTRB(0, 20, 0, 20),
          child: Card(
            child: Padding(
              padding: const EdgeInsets.all(20),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    children: [
                      const FlutterLogo(size: 55),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: const [
                          Text('Overview'),
                          Text(
                            '250.956.261',
                          ),
                        ],
                      ),
                    ],
                  ),
               const Icon(
                    Icons.arrow_right_outlined,
                    size: 30,
                  ),
                ],
              ),
            ),
          ),
        );

我最初将您的问题误解为关于水平居中 ListTile 的内容。要使项目在卡片内垂直居中,您可能只需要禁用 isThreeLine 参数。禁用它会导致内容垂直居中。

构建方法代码:

  @override
  Widget build(BuildContext context) {
    return const Center(
      child: Card(
        child: ListTile(
          leading: FlutterLogo(size: 55),
          title: Text('Overview'),
          subtitle: Text(
            '250.956.261',
          ),
          trailing: Icon(
            Icons.arrow_right_outlined,
            size: 30,
          ),
          // isThreeLine: true,
        ),
      ),
    );
  }