📅  最后修改于: 2022-03-11 15:01:36.248000             🧑  作者: Mango
class TestButton extends StatefulWidget {
TestButton({this.passedcolor});
final Color passedColor;
@override
_TestButtonState createState() => _TestButtonState();
}
class _TestButtonState extends State {
Color color;
@override
initState(){
color = widget.passedColor;
super.initState()
}
@override
Widget build(BuildContext context) {
return RaisedButton(
onPressed: () {
setState(() {
color = color == Colors.red ? Colors.blue : Colors.red;
});
},
child: Icon(
Icons.add,
size: 80,
),
color: color,
);
}
}