Flutter TextButton splashColor 属性 [英] Flutter TextButton splashColor property

查看:21
本文介绍了Flutter TextButton splashColor 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 FlatButton 并传递了属性

I was using FlatButton and passed the properties

FlatButton(
      splashColor: Colors.transparent,
      highlightColor: Colors.transparent,
      child: ..., 
)

文档说 FlatButton 将过时,并使用TextButton 代替,但它不采用 splashColorhighlightColor 属性

The documentation says that FlatButton will become obsolete, and to use TextButton instead, but it does not take splashColor or highlightColor properties

TextButton(                  
    splashColor: Colors.transparent,
    highlightColor: Colors.transparent,
    child: ...,       
)

不起作用.这是不允许的

does not work. it is not allowed

我也试过这样

TextButton(            
  style: ButtonStyle(
    splashColor: Colors.transparent,
    highlightColor: Colors.transparent,
  ),
  child: ..., 
)

我该怎么做?谢谢

推荐答案

Colors.transparent 将拒绝任何效果,只是它是透明的,所以它看起来就像什么都没有发生......在 ButtonStyle 中,它与颜色类似.

Colors.transparent will deny any effects, simply it is transparent so it will appear as nothing happens... in ButtonStyle, it goes something like this with colors.

ButtonStyle(
   overlayColor: MaterialStateColor.resolveWith((states) => Colors.red),
),

这篇关于Flutter TextButton splashColor 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆