小编chr*_*ico的帖子

ListTile 小部件:定义颜色时没有飞溅效果

在我的项目中,我有一个需要应用背景颜色的 ListTile 列表。通过应用颜色,ListTiles 会失去 onTap 飞溅效果。

  • 我尝试使用ListTiles的tileColor属性来实现背景颜色
  • 我尝试通过在子项中传递 ListTile 来实现容器中的背景颜色,但没有成功
// 1 (splash effect working)
ListTile(title: Text("ListTile without color"), onTap: () {}),


// 2 (splash no effect working)
ListTile(
         tileColor: Colors.blue,
         title: Text("ListTile with color"),
         onTap: () {}),


// 3 (splash no effect working)
Container(
         color: Colors.blue,
         child: ListTile(
         title: Text(
                    "ListTile without color in container with color"),
                     onTap: () {}))
Run Code Online (Sandbox Code Playgroud)

完整示例:

// Copyright (c) 2019, the Dart project authors.  Please see the AUTHORS file
// for details. All rights …
Run Code Online (Sandbox Code Playgroud)

dart flutter

5
推荐指数
1
解决办法
3796
查看次数

标签 统计

dart ×1

flutter ×1