flutter ListTile添加边框

Scaffold(
      appBar: AppBar(title: const Text('KindaCode.com')),
      body: Padding(
        padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
        // implement add ListView that contains multiple ListTiles
        child: ListView(
          children: [
            // using StadionBorder
            const ListTile(
              shape: StadiumBorder(
                side: BorderSide(color: Colors.blue, width: 1),
              ),
              iconColor: Colors.blue,
              leading: Icon(
                Icons.shop,
                size: 30,
              ),
              title: Text('Item One'),
              subtitle: Text('StadionBorder'),
              trailing: Icon(
                Icons.play_arrow,
                size: 30,
              ),
            ),
            const SizedBox(
              height: 30,
            ),

            // Using BeveledRectangleBorder
            const ListTile(
              shape: BeveledRectangleBorder(
                side: BorderSide(color: Colors.green, width: 1),
              ),
              iconColor: Colors.green,
              leading: Icon(
                Icons.run_circle,
                size: 30,
              ),
              title: Text('Item Two'),
              subtitle: Text('BeveledRectangleBorder'),
              trailing: Icon(
                Icons.play_arrow,
                size: 30,
              ),
            ),
            const SizedBox(
              height: 30,
            ),

            // Using RoundedRectangleBorder
            ListTile(
              shape: RoundedRectangleBorder(
                side: const BorderSide(color: Colors.orange, width: 4),
                borderRadius: BorderRadius.circular(15),
              ),
              iconColor: Colors.orange,
              leading: const Icon(
                Icons.light,
                size: 30,
              ),
              title: const Text('Item Two'),
              subtitle: const Text('RoundedRectangleBorder'),
              trailing: const Icon(
                Icons.play_arrow,
                size: 30,
              ),
            ),
          ],
        ),
      ),
);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Flutter ListTile是一个常用的UI组件,用于在列表中展示相关信息。它提供了一个整洁的外观和常见的交互模式,使得在Flutter应用中显示列表项变得简单。 ListTile通常用于在FlutterListView或GridView中展示每个列表项。它可以显示标题、副标题、前置图标、后置图标等内容。 在使用ListTile时,你可以设置以下属性: 1. title:列表项的主要内容,通常是一个Text或RichText组件。 2. subtitle:列表项的副标题,通常是一个Text或RichText组件。 3. leading:列表项的前置图标,通常是一个Icon或Image组件。 4. trailing:列表项的后置图标,通常是一个Icon或Image组件。 5. onTap:点击列表项时触发的回调函数。 除了以上属性,ListTile还有其他一些属性可以用来自定义样式,例如字体大小、颜色、边距等。 以下是一个使用ListTile的示例代码: ```dart ListView( children: <Widget>[ ListTile( leading: Icon(Icons.person), title: Text('John Doe'), subtitle: Text('Software Engineer'), trailing: Icon(Icons.arrow_forward), onTap: () { // 处理点击事件 }, ), ListTile( leading: Icon(Icons.person), title: Text('Jane Smith'), subtitle: Text('UI Designer'), trailing: Icon(Icons.arrow_forward), onTap: () { // 处理点击事件 }, ), // 其他列表项... ], ) ``` 这段代码创建了一个包含两个ListTileListView,每个ListTile代表一个人员信息,包括姓名、职位等内容。你可以根据自己的需求进行修改和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值