如何将应用栏的图标按钮居中

问题描述 投票:0回答:1

我正在使用Flutter应用程序,并在Appbar中看到了一个问题。图标按钮不在应用栏的中央。

.

这是我的代码

appBar: AppBar(
    automaticallyImplyLeading: false,
    actions: <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,
      ),
    ],
  ),

预先感谢:)

android-studio flutter android-appbarlayout appbar flutter-appbar
1个回答
0
投票

这是您可以实现的解决方法。

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。

© www.soinside.com 2019 - 2024. All rights reserved.