按下时有没有办法更改浮动按钮的图标?码:
var musicButton = new FloatingActionButton(
onPressed: (){
if(playerState == PlayerState.playing) {
//setState(() => child = new Icon(Icons.pause));
setState((){
child: new Icon(Icons.play_arrow);
});
pause();
} else if (playerState == PlayerState.paused){
setState((){
child: new Icon(Icons.pause);
});
play();
}
},
tooltip: 'Play Music',
child: new Icon(Icons.pause));
1 回答
您可以使用状态变量在图标之间切换 .
例:
然后
希望有所帮助!