dart - float 操作按钮 : how to change the splash color and highlight color like in a RaisedButton?

标签 dart flutter floating-action-button

我看到 FAB 采用的启动颜色和高亮颜色与 MaterialApp 小部件中的参数颜色相关联。有没有办法覆盖这些颜色?我只找到前景色和背景色,而这些不是我想要的。谢谢

最佳答案

如果您查看 FloatingActionButton 的源代码,启动颜色与应用程序的主题相关联,因此您可以仅为按钮更改主题,如下所示:

Theme(
  data: Theme.of(context).copyWith(highlightColor: Colors.yellow),
  child: FloatingActionButton(
    backgroundColor: Colors.red,
    onPressed: () {},
    child: Text("hello world"),
 ),
)

关于dart - float 操作按钮 : how to change the splash color and highlight color like in a RaisedButton?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54608976/

相关文章:

flutter - 如何限制 TextSpan 小部件的文本长度

flutter - Cloud Firestore在APK Release模式下使应用程序崩溃

dart - 如何在 flutter 中将图像设置为墙纸?

firebase - 使用Firestore快照中的StreamController的StreamBuilder

Flutter InteractiveViewer 无法平移/滚动

android - 两个带有折叠工具栏的 FAB

android - Flutter-如何从静态列表中进行动态下拉列表?

error-handling - Flutter:关闭互联网连接后出错 - "Error while applying io.flutter.console.FlutterConsoleFilter@70f92821 to ' W/zzajf (5265)”

android - 在带有 behavior_overlapTop 的 CoordinatorLayout 中使用 float 操作按钮

具有动态状态的 Flutter float 操作按钮