我看到 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/