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

Flutter中如何修改TextButton水波纹效果或完全移除它?

解决TextButton点击蓝色效果的问题

你可以通过修改TextButton的样式来调整或移除点击时的高亮效果:

1. 完全移除点击效果

将overlayColor设置为透明色,即可去掉点击时的蓝色高亮:

SizedBox(
  width: 145,
  height: 146,
  child: TextButton(
    style: TextButton.styleFrom(
      overlayColor: Colors.transparent,
    ),
    child: const Text('Mentor'),
    onPressed: () {},
  ),
)

2. 将点击效果改为黄色

把overlayColor设置为黄色(可搭配透明度调整视觉柔和度):

SizedBox(
  width: 145,
  height: 146,
  child: TextButton(
    style: TextButton.styleFrom(
      overlayColor: Colors.yellow.withOpacity(0.3),
    ),
    child: const Text('Mentor'),
    onPressed: () {},
  ),
)

如果需要更灵活的样式控制,也可以用ButtonStyle定义:

SizedBox(
  width: 145,
  height: 146,
  child: TextButton(
    style: ButtonStyle(
      overlayColor: MaterialStateProperty.all(Colors.yellow.withOpacity(0.3)),
    ),
    child: const Text('Mentor'),
    onPressed: () {},
  ),
)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 06:13:12