【问题标题】:Get rid of ripple effect TextButton Flutter摆脱涟漪效应 TextButton Flutter
【发布时间】:2021-07-08 13:34:23
【问题描述】:

自从 Flutter 弃用 FlatButton 后,我不能再使用 splashColor 和 highlightColor 属性来设置用户按下按钮时的颜色。现在我必须使用其中一个新按钮,例如下面的 TextButton,但我还没有找到任何具有背景颜色功能的 buttonStyles,当用户按下按钮时,不会产生涟漪效应。

TextButton(
 style: ButtonStyle(
  overlayColor: MaterialStateProperty.all(Colors.grey[100]),
 ),
),

【问题讨论】:

    标签: flutter


    【解决方案1】:

    回复晚了,可以在ButtonStyle上使用splashFactory属性。

    TextButton(
      style: TextButton.styleFrom(
        splashFactory: NoSplash.splashFactory
      ),
    ),
    

    【讨论】:

      【解决方案2】:

      为了涟漪效果,将TextButton 包裹在InkWell 小部件中,如下所示:

      InkWell(
       TextButton(
        style: ButtonStyle(
        overlayColor: MaterialStateProperty.all(Colors.grey[100]),
        ),
       ),
      )
      

      【讨论】:

      • 我不要涟漪效应,我要摆脱涟漪效应
      猜你喜欢
      • 1970-01-01
      • 2016-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-07
      • 2017-03-10
      • 2018-02-23
      • 1970-01-01
      相关资源
      最近更新 更多