flutter 如何消除可点击透明容器的涟漪效应?

qoefvg9y  于 2023-03-19  发布在  Flutter
关注(0)|答案(4)|浏览(118)

我想从一个透明的可点击容器中删除涟漪效果,但无论我做什么效果都不会消失,请帮助!
代码:

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

ktca8awb1#

使用GestureDetector代替:

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

eoxn13cs2#

在您的材料应用程序小部件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,
)
qlzsbp2j

qlzsbp2j3#

我是这样使用它的:

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,
);
smdnsysy

smdnsysy4#

使用GestureDetector而不是InkWell,因为Inkwell默认提供涟漪效果,因此您可以使用GestureDetector。

相关问题