簡體   English   中英

如何在顫動中將 Appbar 的 IconButton 居中

[英]How to center the IconButton of Appbar in flutter

我使用顫振應用程序並在應用欄中看到一個問題。 圖標按鈕不在應用欄的中心。

這是我的代碼。

appBar: AppBar(
    automaticallyImplyLeading: false,
    actions: <Widget>[
      IconButton(
          icon: Icon(Icons.home),
          onPressed: null,
      )
    ],
  ),

IconButton 不在應用欄或導航欄的中心。

這是您可以采取的一種解決方法來實現這一點,因為操作通常在標題之后,如文檔所述AppBar class

appBar: AppBar(
            automaticallyImplyLeading: false,
            centerTitle: true,
            title: Row(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                IconButton(
                  icon: Icon(Icons.home),
                  onPressed: null,
                ),
                IconButton(
                  icon: Icon(Icons.trending_up),
                  onPressed: null,
                ),
                IconButton(
                  icon: Icon(Icons.people_outline),
                  onPressed: null,
                ),
                IconButton(
                  icon: Icon(Icons.person_outline),
                  onPressed: null,
                ),
                IconButton(
                  icon: Icon(Icons.notifications_none),
                  onPressed: null,
                ),
                IconButton(icon: Icon(Icons.search), onPressed: null),
                IconButton(
                  icon: Icon(Icons.brightness_5),
                  onPressed: null,
                ),
              ],
            )),

但也許您應該考慮在您的情況下使用 TabBar。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM