【问题标题】:hoverColor property of the Raised button class in Flutter, doesn't change?Flutter 中 Raised 按钮类的 hoverColor 属性,不会改变吗?
【发布时间】:2020-01-20 12:54:54
【问题描述】:

编辑:我使用的是 IOS 模拟器,以下问题可能不会在所有平台上都存在。

我的印象是,在创建 RaisedButton 时,可以在光标悬停在按钮上时更改按钮的颜色。

然而情况似乎并非如此。

// 创建按钮

RaisedButton(
    onPressed: () {},
    color: Colors.redButtonBackgroundColo
    textColor: Colors.white,
    disabledColor: Colors.disabledRedButtonBackgroundColor,
    disabledTextColor: Colors.white,
    disabledElevation: 4,
    elevation: 4,
    hoverColor: Colors.redHoveredOverButtonColor, //<--- Here is where I would like to change the button color (to a slightly lighter shade.)
    padding: const EdgeInsets.all(14.0),      
 ),        

提前感谢您提供的任何帮助。

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    由于问题不是很清楚,我将假设一些事情。 首先,您在 flutter 桌面web 上运行应用程序。 在这种情况下,代码应该可以正常工作。

    如果您在移动设备上尝试,那么移动设备上没有悬停动作,这就是按钮不会改变颜色的原因。

    如果您想在点击时更改颜色,则可以使用 GestureDetector 包装 RaisedButton使用 onTap 或 onPanDown 回调手动更改按钮的颜色。

    【讨论】:

      猜你喜欢
      • 2021-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-02
      • 2020-06-06
      • 2018-07-17
      相关资源
      最近更新 更多