flutter更改utils常量颜色的颜色,在应用程序屏幕中使用按钮



我写了一个大软件,我试图为整个软件使用两种主要颜色。我想通过按下一个按钮来改变软件的整体颜色。我需要你的帮助。

在lib/utils上:SO:他们不在班上,

const d=来自ARGB的颜色(255184233,8(;

const w=Color.fromARGB(255255255255(;

在我制作的每一页上,我都像在代码下一样使用它来改变我使用的颜色:

颜色:d,

颜色:w,

现在我做了按钮,想像一样使用它

AppBar(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(25.0),
bottomRight: Radius.circular(25.0))),
toolbarHeight: 40,
backgroundColor: d,
foregroundColor: w,
bottomOpacity: 0.1,
centerTitle: false,
title: SvgPicture.asset(
'assets/ic_instagram.svg',
color: primaryColor,
height: 25,
),
actions: [
IconButton(
icon: Icon(
Icons.mail,
color: Color.fromARGB(255, 255, 0, 191),
),
onPressed: () {
setState(() {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => colorset(),
),
);
});
},
),
IconButton(
icon: Icon(
Icons.mail,
color: Color.fromARGB(255, 1, 132, 255),
),
onPressed: () {
setState(() {
d.update(d: Color.fromARGB(255, 1, 132, 255));
});
},
),
],
),

如何更改utils中const值的颜色?

如果您想更改颜色变量,为什么不删除常量?

对不再变化的变量(例如PI(使用常量

Color w = Color.fromARGB(255, 184, 233, 8);

最新更新