flutter 如何修改返回按鈕的顏色


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,
),

更改之后的效果圖如下:

 

謝謝大家!!!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM