简体   繁体   English

Flutter 可滚动的列,带有展开的子项并在容器内

[英]Flutter scrollable column with expanded children and inside a container

I am struggling with making the column scrollable:我正在努力使该列可滚动:

Container(
    height: double.infinity,
    width: double.infinity,
    color: Colors.blue,
    child: Column(
      children: [
      Expanded(flex: 2, child...),
      Expanded(flex: 5, child...)
      ]
    )
)

I tried wrapping all the widget inside a single child scroll view, I tried a list view and I tried combing layout builder but nothing works我尝试将所有小部件包装在一个子滚动视图中,我尝试了一个列表视图,我尝试组合布局构建器但没有任何效果

When you use expanded you should have a limited space (height in column and width in row), in your case your height will fit the space in screen.当您使用扩展时,您应该有一个有限的空间(列高和行宽),在您的情况下,您的高度将适合屏幕空间。 If you change the column to the scrollview even change it directly to the ListView or swap it with the SingleChildScrollView, you will have unlimited space and you can't use expanded widget, because it wants to fill all possible space, and it is unlimited in scrollview如果你把column改成scrollview甚至直接改成ListView或者换成SingleChildScrollView,你就会有无限的空间,你不能使用展开的widget,因为它想填满所有可能的空间,而且它是无限的滚动视图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM