You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除Flutter中ExpansionTile组件的点击按压颜色

移除ExpansionTile点击按压状态的颜色

要去掉ExpansionTile点击时的按压颜色,你可以通过以下两种常用方法实现:

  • 方法一:用Theme组件包裹修改全局按压颜色
    直接在ExpansionTile外层套一个Theme,将水波纹颜色和高亮颜色设为透明:

    Theme(
      data: ThemeData(
        splashColor: Colors.transparent,
        highlightColor: Colors.transparent,
      ),
      child: ExpansionTile(
        title: const Text("折叠标题"),
        children: const [
          Padding(
            padding: EdgeInsets.all(16.0),
            child: Text("折叠内容"),
          )
        ],
      ),
    )
    
  • 方法二:用ListTileTheme精准修改Tile的按压样式
    因为ExpansionTile的点击区域本质是ListTile,用ListTileTheme包裹可以只针对该组件修改:

    ListTileTheme(
      splashColor: Colors.transparent,
      highlightColor: Colors.transparent,
      child: ExpansionTile(
        title: const Text("折叠标题"),
        children: const [
          Padding(
            padding: EdgeInsets.all(16.0),
            child: Text("折叠内容"),
          )
        ],
      ),
    )
    

原理:ExpansionTile的按压颜色默认继承自当前Theme的splashColor(水波纹)和highlightColor(高亮),将这两个颜色设为透明即可消除点击时的颜色变化。

内容的提问来源于stack exchange,提问作者Mohammed

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 11:25:34