[flutter]如何全局去掉iOS下的水波纹效果?

先定义2种不同场景下的颜色(p.s.我这里用到暗黑主题,不需要的可以去掉)

class _DarkColors {
  static final highlightColor = const Color(0x40CCCCCC);
  static final splashColor = const Color(0x40CCCCCC);
}
class _LightColors {
  static final highlightColor = const Color(0x66BCBCBC); 
  static final splashColor = const Color(0x66C8C8C8);
}
static final ThemeData themeDataLight = ThemeData(
    //关键代码就这个:
    //iOS不需要水波纹
    highlightColor: Platform.isAndroid ? _LightColors.highlightColor : Colors.transparent,
    splashColor: Platform.isAndroid ? _LightColors.splashColor : Colors.transparent,
);
static final ThemeData themeDataDark = ThemeData(
    highlightColor: Platform.isAndroid ? _DarkColors.highlightColor : Colors.transparent,
    splashColor: Platform.isAndroid ? _DarkColors.splashColor : Colors.transparent,
);

能看懂吧?对了,上面的颜色取值是从源码theme_data.dart里复制过来的,各位可以放心使用。

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 带你高效入门 Flutter 本文面向 Flutter 初学者,旨在用易懂的方式带大家入门。除了 Flutter ...
    叶情宇阅读 3,005评论 0赞 5
  • 本文面向 Flutter 初学者,旨在用易懂的方式带大家入门。除了 Flutter 代码,还会介绍到语法、原理、特...
    NanBox阅读 3,079评论 0赞 6
  • 看好的衣服配好看的人穿。我所说的好看,是你觉着的好看。
    徐三岁97阅读 150评论 0赞 0
  • 人活一辈,生命活一世都是空的,什么你都捞不着,皮囊骨架回归自然一浊泥土,一滴污水,一缕异气很快就无踪无影。...
    孱夫子阅读 439评论 0赞 0
  • 右侧肩膀特别紧张 为什么自己惠喋喋不休的找人诉说 ?是我都明白道理,可是我却不愿意去面对?我只想一直这样自欺欺人的...
    臻悉阅读 114评论 0赞 0

友情链接更多精彩内容