首页 > 解决方案 > 我如何在颤动中增加bottomAppbar的高度

问题描述

我的应用程序中有一个 BottomAppBar,但高度似乎只是环绕其中的图标。我想给bottomappbar更多的高度,请问我该怎么做

   bottomNavigationBar: BottomAppBar(
          child: Row(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
                Icon(Icons.category),
                Icon(Icons.account_circle),
                Icon(Icons.message),
                Icon(Icons.access_alarm)
            ],
          ),
    elevation: 9.0,
    shape: CircularNotchedRectangle(),
    color: Colors.white,
    notchMargin: 8.0,
  ),

标签: dartflutter

解决方案


您可以为图标添加填充:

BottomAppBar(
        child: Row(
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.all(15.0),
              child: Icon(Icons.category),
            ),
            Padding(
              padding: const EdgeInsets.all(15.0),
              child: Icon(Icons.account_circle),
            ),
            Padding(
              padding: const EdgeInsets.all(15.0),
              child: Icon(Icons.message),
            ),
            Padding(
              padding: const EdgeInsets.all(15.0),
              child: Icon(Icons.access_alarm),
            )
          ],
        ),
        elevation: 9.0,
        shape: CircularNotchedRectangle(),
        color: Colors.white,
        notchMargin: 8.0,
      )

另一个解决方案:我正在使用BottomNavigatorBar并且它有一个属性iconSize

BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        iconSize: 35,


        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
              icon: Icon(Icons.explore), title: Text('Explore')),
          BottomNavigationBarItem(
              icon: Icon(Icons.card_travel), title: Text('Adventure')),
          BottomNavigationBarItem(
              icon: Icon(Icons.search), title: Text('Search')),
          BottomNavigationBarItem(
              icon: Icon(Icons.collections_bookmark), title: Text('Bookmarks')),
          BottomNavigationBarItem(
              icon: Icon(Icons.person), title: Text('Profile')),
        ],
        currentIndex: _selectedIndex,
        fixedColor: Colors.deepPurple,
        onTap: _onItemTapped,
      )

推荐阅读