flutter 如何修改返回按鈕的顏色
如果想設置AppBar返回按鈕的顏色,可以通過修改相對應主題色的方式來完成,示例代碼如下:
appBar: AppBar(
iconTheme: IconThemeData(
color: Colors.black, //修改顏色
),
title: Text("示例"),
centerTitle: true,
),
當然你也可以自定義返回按鈕,代碼如下:
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.black),
onPressed: () => Navigator.of(context).pop(),
),
title: Text("示例"),
centerTitle: true,
),
還可以這樣做:
appBar: AppBar(
leading: BackButton(
color: Colors.black
),
title: Text("示例"),
centerTitle: true,
),
更改之後的效果圖如下:
謝謝大家!!!