如何更改appBar后退按钮的颜色
问题内容:
我无法弄清楚如何将appBar的自动后退按钮更改为其他颜色。它在一个脚手架下,我曾尝试对其进行研究,但我无法将其包裹住。
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
title: Image.asset(
'images/.jpg',
fit: BoxFit.fill,
),
centerTitle: true,
),
问题答案:
您必须使用iconTheme
AppBar 的属性,如下所示:
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,
),