Flutter 将列添加到底部的appbar使其全屏显示

Flutter 将列添加到底部的appbar使其全屏显示,flutter,flutter-layout,Flutter,Flutter Layout,我有一个底部有两个图标的应用程序栏。我想在图标下面添加文本,所以我想我应该将我的图标按钮包装在一列中。当我这样做时,它会导致底部应用程序栏占据整个屏幕。我怎样才能解决这个问题?以下是导致问题的代码。它在没有列的情况下按预期工作 bottomNavigationBar: BottomAppBar( color: Colors.blueGrey, shape: CircularNotchedRectangle(), child: Row( mainAxisSize

我有一个底部有两个图标的应用程序栏。我想在图标下面添加文本,所以我想我应该将我的图标按钮包装在一列中。当我这样做时,它会导致底部应用程序栏占据整个屏幕。我怎样才能解决这个问题?以下是导致问题的代码。它在没有列的情况下按预期工作

bottomNavigationBar: BottomAppBar(
    color: Colors.blueGrey,
    shape: CircularNotchedRectangle(),
    child: Row(
      mainAxisSize: MainAxisSize.max,
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      children: <Widget>[
        Column(
          children: [
            IconButton(
              icon: Icon(Icons.note_add),
              color: Colors.white,
              // tooltip: 'Add Note',
              onPressed: () => _startAddNewNote(context),
            ),
            Text('Add Note'),
          ],
        ),
        Column(
          children: [
            IconButton(
              icon: Icon(Icons.image),
              color: Colors.white,
              // tooltip: 'Open Image Clue',
              onPressed: () => _startShowImageClue(context),
            ),
            Text('Open Image Clue'),
          ],
        ),
      ],
    ),
  ),
bottomNavigationBar:BottomAppBar(
颜色:颜色。蓝灰色,
形状:CircularNotchedRectangle(),
孩子:排(
mainAxisSize:mainAxisSize.max,
mainAxisAlignment:mainAxisAlignment.spaceAround,
儿童:[
纵队(
儿童:[
图标按钮(
图标:图标(图标。注释\u添加),
颜色:颜色,白色,
//工具提示:“添加注释”,
按下按钮:()=>_startAddNewNote(上下文),
),
文本(“添加注释”),
],
),
纵队(
儿童:[
图标按钮(
图标:图标(Icons.image),
颜色:颜色,白色,
//工具提示:“打开图像线索”,
按下:()=>_开始显示图像线索(上下文),
),
文本(“打开图像线索”),
],
),
],
),
),
在我添加列之前

这是该列对屏幕所做的操作


列的大小更改为
MainAxisSize.min
即可

Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        IconButton(
          icon: Icon(Icons.note_add),
          color: Colors.white,
          // tooltip: 'Add Note',
          onPressed: () {},
        ),
        Text('Add Note'),
      ],
    ),
    Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        IconButton(
          icon: Icon(Icons.image),
          color: Colors.white,
          // tooltip: 'Open Image Clue',
          onPressed: () {},
        ),
        Text('Open Image Clue'),
      ],
    ),
还有一个用于制作BottomNavigationBarItem的预构建小部件,您可以像

BottomNavigationBarItem(icon:IconButton(
          icon: Icon(Icons.image),
          color: Colors.white,
          // tooltip: 'Open Image Clue',
          onPressed: () {},
        ),label:"Open Image Clue",
)

建议使用此选项,因为它有一些文本缩放实现

尝试将列主轴大小设置为minYeah,现在可以了。