改变浮动操作按钮颤动的颜色
Changing Color of Floating Action Button Flutter
我想在按下浮动按钮时更改浮动按钮的颜色,但找不到解决方法,我该如何解决?提前致谢。
var color1;
var floatingActionButton1 = FloatingActionButton(
onPressed: () {
setState(() {
simpleInterest.principal = double.parse(_principalController.text);
color1 = Colors.green;
});
},
elevation: 40,
backgroundColor: color1,
heroTag: "btn1",
child: Icon(Icons.check),
);
查看代码:
var isPressed = false;
.....
floatingActionButton: FloatingActionButton(
child: Icon(Icons.check),
backgroundColor: isPressed ? Colors.green : Colors.blue,
onPressed: () => setState(() => isPressed = !isPressed),
),
我想在按下浮动按钮时更改浮动按钮的颜色,但找不到解决方法,我该如何解决?提前致谢。
var color1;
var floatingActionButton1 = FloatingActionButton(
onPressed: () {
setState(() {
simpleInterest.principal = double.parse(_principalController.text);
color1 = Colors.green;
});
},
elevation: 40,
backgroundColor: color1,
heroTag: "btn1",
child: Icon(Icons.check),
);
查看代码:
var isPressed = false;
.....
floatingActionButton: FloatingActionButton(
child: Icon(Icons.check),
backgroundColor: isPressed ? Colors.green : Colors.blue,
onPressed: () => setState(() => isPressed = !isPressed),
),