如何动态改变一个Appbar和一个按钮的按钮的背景颜色?



我想用一个按钮和它的onPressed函数来改变AppBar,文本和按钮的颜色。

我想要颜色更新时,点击/按下按钮。

AppBar、text和button的颜色都是不同的。

创建两个变量来存储颜色值

Color _appBarColor = Colors.blue , _textColor=Colors.white;

改变按下按钮的变量值

onTap:(){
_appBarColor = Colors.grey;
_textColor = Colors.white;
setState((){}); //-> To Change the state of the screen
}

最新更新