【发布时间】:2022-08-19 15:59:36
【问题描述】:
这是我想要的设计:
这是我目前的设计:
您好,如何使按钮在按下时更改颜色并转到按下的页面。例如,当您按下配置文件按钮时,颜色会发生变化。当您转到另一个页面时,按钮的颜色将变为白色。谁能帮我?
这是我的代码:
ElevatedButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(
EdgeInsets.fromLTRB(30, 20, 30, 20),
),
// overlayColor: MaterialStateProperty.all(Colors.red),
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed))
return Colors.blue;
return Color.fromARGB(255, 0, 79, 143);
}
),
),
onPressed: () {},
child: new Text(
\'Profile\',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal
)
),
),