在ListTile中半径大于27的Flutter CircleAvatar变成了一个椭圆。

问题描述 投票:0回答:1

我遇到了一个问题,我需要一个半径为35的CircleAvatar,但是任何超过27的东西,放在ListTile中就会变成一个椭圆,限制了高度。在上面的容器中,它的半径为40,可以正常显示。有什么好办法吗?

           Card(
              elevation: 0,
              child: ListTile(
                leading: CircleAvatar(
                  radius: 27,
                  backgroundImage: AssetImage('images/sophia_hs.jpg'),
                ),
                title:
                Text("Sophia Daniels",
                  style: TextStyle(
                    fontFamily: 'Roboto',
                    color: Colors.black,
                    fontSize: 20,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                subtitle:
                Text("Casting Director",
                  style: TextStyle(
                    fontFamily: 'Roboto',
                    color: Colors.black,
                    fontSize: 16,
                    fontWeight: FontWeight.normal,
                  ),
                ),
              ),
            ),
            Container(
              height: 120,
              color: Color(0xffffd504),
              child: Center(
                child: ListTile(
                  leading: CircleAvatar(
                    radius: 40,
                    backgroundImage: AssetImage('images/sophia_hs.jpg'),
                  ),
                  dense: false,
                  title: Text("Sophia Daniels",
                    style: TextStyle(
                      fontFamily: 'Roboto',
                      color: Colors.black,
                      fontSize: 20,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  subtitle: Text("Casting Director",
                    style: TextStyle(
                      fontFamily: 'Roboto',
                      color: Colors.black,
                      fontSize: 16,
                      fontWeight: FontWeight.normal,
                    ),
                  ),
                ),
              ),
            ),

请在这里输入图片描述

flutter flutter-layout
1个回答
0
投票

尝试编辑容器的高度,并使其大于120.你也可以尝试Image.Asset()从资产中加载图像。他们有更多的能力来适应图像根据它的大小。

© www.soinside.com 2019 - 2024. All rights reserved.