颤振自动为TabBarView设置高度

时间:2019-09-23 11:53:38

标签: flutter flutter-layout

我的问题是我必须为TabBarView设置固定的高度才能解决RenderBox的错误,不幸的是,此尺寸是固定的,并且不能由孩子的身高扩展。我该如何解决?

我测试了ExpandedSizedBox.expanded,但没有任何变化

Scaffold <----------------parent
    SingleChildScrollView <---child
        Stack   <-----------------child
            Padding <-----------------child
                Column  <-----------------child

                      Container( <--------------child
                      height: 250.0,
                      child: TabBarView(
                        children: [
                          Column(
                          ),
                          Column(
                          ),
                          Column(
                          ),
                        ],
                        controller: tabController,
                      ),
                    ),
                  );

1 个答案:

答案 0 :(得分:1)

我不确定您希望UI的外观如何,但是您可以尝试以下两种解决方案:

  1. 使用val listSizesArray = arrayOf("UK7","UK8","UK9","UK10"); println(listSizesArray.contentToString()); //[UK7, UK8, UK9, UK10] 并提供一些LimitedBox

    maxHeight
  2. 删除SingleChildScrollView( physics: BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()), child: Stack( children: <Widget>[ Column( children: <Widget>[ LimitedBox( // use this maxHeight: 200, // give some maxHeight child: TabBarView( children: [ FlutterLogo(colors: Colors.orange, size: 100,), FlutterLogo(colors: Colors.red, size: 100), ], ), ), SizedBox(height: 50), FlutterLogo(size: 100), SizedBox(height: 100), FlutterLogo(size: 100), ], ), ], ), ) 并添加SingleChildScrollView

    Expanded