Flutter:如何在底部导航栏上向insida添加列小部件

我尝试了以下方法并退出,但身体一片空白。 有什么办法可以在底部导航栏中添加一个列或一个列表视图

 Column(
    mainAxisAlignment:MainAxisAlignment.end,children: <Widget>[
      Row(
        children: <Widget>[
          Expanded(
              //button1
         ),Expanded(
              //button2
               ),Expanded(
             //button3)
      ),Row(
        children: <Widget>[
          Expanded(
            //button4
          ),Expanded(
            //button5)
        ],)
    ],),
yaoliaaa 回答:Flutter:如何在底部导航栏上向insida添加列小部件

除了扩展小部件带来的问题(如the answer by alexandreohara所述)之外,
默认情况下,列的mainAxisSize属性设置为MainAxisSize.max。这意味着该列将尝试占据所有可用空间(整个屏幕高度)。

将Column的mainAxisSize设置为MainAxisSize.min将包裹Column小部件,使其占据(垂直)最小的空间,而不是整个屏幕。

以下是可以完成的方法:

    Column(
        mainAxisSize: MainAxisSize.min,children: [...]
    );
,

在BottomNavigationBar中使用列没有问题。我认为您的问题是将所有内容都包装在Expanded中。它不知道内部小部件的宽度,因此,它将返回空白。

尝试删除那些扩展小部件,然后尝试以下操作:

Row(
   mainAxisAlignment: MainAxisAlignment.spaceBetween
   children: [FlatButton(...),FlatButton(...)],)
本文链接:https://www.f2er.com/3046986.html

大家都在问