gpt4 book ai didi

flutter - 如何更改 appBar 后退按钮颜色

转载 作者:IT老高 更新时间:2023-10-28 13:48:50 26 4
gpt4 key购买 nike

我不知道如何将 appBar 的自动后退按钮更改为不同的颜色。它在一个脚手架下,我试图研究它,但我无法绕着它转。

return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
title: Image.asset(
'images/.jpg',
fit: BoxFit.fill,
),
centerTitle: true,
),

最佳答案

您必须使用 AppBar 中的 iconTheme 属性,如下所示:

appBar: AppBar(
iconTheme: IconThemeData(
color: Colors.black, //change your color here
),
title: Text("Sample"),
centerTitle: true,
),

或者如果你想自己处理后退按钮。

appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.black),
onPressed: () => Navigator.of(context).pop(),
),
title: Text("Sample"),
centerTitle: true,
),

更好的是,仅当您想更改后退按钮的颜色时。

appBar: AppBar(
leading: BackButton(
color: Colors.black
),
title: Text("Sample"),
centerTitle: true,
),

关于flutter - 如何更改 appBar 后退按钮颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51508257/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com