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

问题描述

限时删除!!

我正在使用 FlatButton 并传递了属性

I was using FlatButton and passed the properties

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

文档指出FlatButton将会过时,并且要使用改为使用 TextButton ,但它不具有 splashColor highlightColor 属性

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属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:51