简体   繁体   English

Flutter中如何去除ListTile前导图标的边框?

[英]How to remove borders for ListTile leading icon in Flutter?

I want to use ListTile with borders.我想使用带边框的ListTile But I want to hide borders above and below leading icon.但我想隐藏前导图标上方和下方的边框。 To do something like this.做这样的事情。

在此处输入图像描述

For example, look at Privacy item.例如,查看Privacy项。 It doesn't have borders around leading icon.它没有围绕前导图标的边框。

This is my code:这是我的代码:

ListTile(
  shape: Border(
    bottom: BorderSide(width: 1, color: Colors.grey),
    top: BorderSide(width: 1, color: Colors.grey),
  ),
  leading: Icon(Icons.person, size: 32),
  title: const Text("Contact", style: TextStyle(fontSize: 16),),
)

But it adds borders also above and below icon.但它也在图标上方和下方添加了边框。 Could anyone say how to do it?有人能说怎么做吗?

This UI is grouping item.此 UI 是分组项目。 There are others way of doing it.还有其他方法可以做到这一点。 Here are three items( itemCount:3 ) and It is inside ListView.separated .这是三个项目( itemCount:3 ),它位于ListView.separated内。 Every Item(group) have border Radius.每个项目(组)都有边界半径。

A single item can be Wrapped with Column to contain children and again wrapped with another widget单个项目可以用 Column 包装以包含子项,并再次用另一个小部件包装

ListView.separated(
    itemBuilder: (context, index) {
      return ClipRRect(
        borderRadius: BorderRadius.circular(24),
        child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            children: [...],
          ),
        ),
      );
    },
    separatorBuilder: (_, __) => SizedBox(
          height: 20,
        ),
    itemCount: 3),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM