flutter - 在 ListTile 中更改 CircleAvatar 大小

标签 flutter listview user-interface mobile

我想增加 CircleAvatar 的大小作为 Listtile 的引导。但是如果我增加半径,圆就不会保持其比例并变成椭圆。
这是我的代码:

ListView.builder(
itemCount: friendlist.length,
itemBuilder: (BuildContext context, int index) {
print(friendlist[index]);
return ListTile(
        title: Text(friendlist[index]["nickname"],
                style: TextStyle(fontSize: 20)),
        leading: CircleAvatar(
            radius: 50,
            backgroundColor: Colors.transparent,
            backgroundImage: CachedNetworkImageProvider(core.url + "profiles/" + friendlist[index]["avatar_id"]),
          ),
        subtitle:
        Text(friendlist[index]["lost_last"])
    );
}));
我试过的:
  • 将圆形头像嵌套到固定宽度和高度的容器中->圆形仍然是椭圆
  • 改变 ListView.builder 的 ItemExtent -> The Circle 仍然不能使用所有的空白空间并变成一个椭圆。

  • 谢谢

    最佳答案

    ListTitle 目前无法做到这一点,因为这是他们为小部件标准添加的应用限制

    To be accessible, tappable leading and trailing widgets have to be at least 48x48 in size. However, to adhere to the Material spec, trailing and leading widgets in one-line ListTiles should visually be at most 32 (dense: true) or 40 (dense: false) in height, which may conflict with the accessibility requirement.


    您可以根据您的要求创建自定义小部件。

    关于flutter - 在 ListTile 中更改 CircleAvatar 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62730770/

    相关文章:

    java - ArrayAdapter 可能导致应用程序崩溃

    wpf - 如何制作具有交替行颜色和固定颜色部分的 WPF DataGrid(忽略交替)

    java - 出现编译错误列表,然后在Eclipse中迅速消失

    intellij-idea - Flutter - 在 IntelliJ 中使用 Atom 语法高亮

    flutter - Flutter Item ExpansionPanelList不会更改状态

    flutter - 什么时候关闭 Flutter 应用程序中的 HTTP 客户端?

    android - 加载 InterstitialAd 时 Flutter App 崩溃

    rest - 如何使 flutter 中的无限滚动布局? (更新)

    android - 将 ListView 项转换为单个位图图像

    ios - 如何在顶部显示消息?