如何从可点击的透明容器中删除波纹效应?

问题描述 投票:0回答:5

我想从透明可点击容器中删除波纹效果,但无论我做什么,效果都不会消失,请帮忙!

代码:

InkWell(
 onTap: (){print('Tapped');},
   child: Container(
     height: 200, width: 200,),)
flutter flutter-layout containers ripple-effect
5个回答
3
投票

将以下行放入您的 Material App Widget ThemeData

highlightColor: Colors.transparent,
hoverColor: Colors.transparent,
splashColor: Colors.transparent,
splashFactory: NoSplash.splashFactory,

喜欢

theme: ThemeData(
      highlightColor: Colors.transparent,
      hoverColor: Colors.transparent,
      splashColor: Colors.transparent,
      splashFactory: NoSplash.splashFactory,
)

2
投票

使用

GestureDetector
代替:

GestureDetector(
 onTap: () {print('Tapped');},
   child: Container(
     height: 200, width: 200,
   ),
 )

1
投票

我这样使用它:

InkWell(
  excludeFromSemantics: true,
  canRequestFocus: false,
  enableFeedback: false,
  splashFactory: NoSplash.splashFactory,
  splashColor: Colors.transparent,
  highlightColor: Colors.transparent,
  focusColor: Colors.transparent,
  hoverColor: Colors.transparent,
  overlayColor: MaterialStateProperty.all(Colors.transparent),
  onTap: widget.onPressed,
  child: child,
);

1
投票

使用

GestureDetector
代替
InkWell
,因为Inkwell默认提供波纹效果,所以你可以使用GestureDetector。


0
投票

回复有点晚了,但也许这会对其他人有所帮助 - 要消除单击 InkWell 子项时的连锁反应,需要设置以下 3 个属性 -

InkWell(
      onTap: () => onChanged(value),
      splashColor: Colors.transparent,
      highlightColor: Colors.transparent,
      enableFeedback: false,
);

enableFeedback = false
将删除默认情况下单击按钮时通常播放的点击声音。
splashColor
highlightColor
将消除在调用 onTap 时导致小部件周围形成灰色波纹的飞溅效果。

© www.soinside.com 2019 - 2024. All rights reserved.