【问题标题】:How do you remove RIPPLE EFFECT from a CLICKABLE TRANSPARENT CONTAINER?如何从可点击的透明容器中移除涟漪效应?
【发布时间】:2021-12-03 09:41:29
【问题描述】:

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

代码:

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

【问题讨论】:

  • 选择InkWell的主要目的是享受它的“涟漪效应”。如果您不想要它,请改用GestureDetector

标签: flutter flutter-layout containers ripple-effect


【解决方案1】:

改用GestureDetector

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

【讨论】:

    【解决方案2】:

    在您的 Material App 小部件 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,
    )
    

    【讨论】:

      猜你喜欢
      • 2019-06-05
      • 2016-06-05
      • 2020-03-10
      • 2021-03-18
      • 2016-12-02
      • 1970-01-01
      • 2022-12-22
      • 1970-01-01
      • 2016-04-25
      相关资源
      最近更新 更多