我想改变按钮的颜色,当我点击它。你能帮帮我吗,因为我真的做不到。谢谢你的帮助。
Container(
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
new MaterialButton(
child: new Text("1"),
color: Colors.greenAccent,
splashColor: Colors.red,
onPressed: (){
test=0;
test=1;
},
),
new MaterialButton(
child: new Text("2"),
color: Colors.greenAccent,
onPressed: (){
test=0;
test=2;
},
尝试像这样
Color mySplashColor=Colors.blue; //define in build function or state class
splashColors: mySplashColor,
onPressed(){
setState(){
splashColors=Colors.red;
}
}