我想从透明可点击容器中删除波纹效果,但无论我做什么,效果都不会消失,请帮忙!
代码:
InkWell(
onTap: (){print('Tapped');},
child: Container(
height: 200, width: 200,),)
将以下行放入您的 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,
)
使用
GestureDetector
代替:
GestureDetector(
onTap: () {print('Tapped');},
child: Container(
height: 200, width: 200,
),
)
我这样使用它:
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,
);
使用
GestureDetector
代替InkWell
,因为Inkwell默认提供波纹效果,所以你可以使用GestureDetector。
回复有点晚了,但也许这会对其他人有所帮助 - 要消除单击 InkWell 子项时的连锁反应,需要设置以下 3 个属性 -
InkWell(
onTap: () => onChanged(value),
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
enableFeedback: false,
);
enableFeedback = false
将删除默认情况下单击按钮时通常播放的点击声音。 splashColor
和 highlightColor
将消除在调用 onTap 时导致小部件周围形成灰色波纹的飞溅效果。