简体   繁体   English

如何摆脱InkWell小部件上的动画?

[英]How can I get rid of the animation on the InkWell widget?

I have a problem. 我有个问题。 I have an InkWell widget but I don't want it to have that splash screen animation. 我有一个InkWell小部件,但我不希望它具有启动屏幕动画。 Is there a way to get rid of this animation? 有办法摆脱这种动画吗?

If you don't care about the splash animation, do not use InkWell . 如果您不关心启动动画,请不要使用InkWell That widget exists only for that. 该小部件仅用于此目的。

Instead use GestureDetector , which is basically an InkWell without the animation. 而是使用GestureDetector ,它基本上是没有动画的InkWell

InkWell Widget has a SplashColor property InkWell小部件具有SplashColor属性

class Whatever extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // The InkWell Wraps our custom flat button Widget
    return InkWell(
      // When the user taps the button, show a snackbar
      onTap: () { /*or your custom implementation*/
        Scaffold.of(context).showSnackBar(SnackBar(
          content: Text('Tap'),
        ));
      },
      splashColor: Colors.transparent, /*This is what you need to include*/
      child: Container(
        padding: EdgeInsets.all(12.0),
        child: Text('Flat Button'),
      ),
    );
  }
}

如果您不希望有任何反馈,则可以添加splashColor: Colors.transparenthighlightColor: Colors.transparent

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM