繁体   English   中英

在 flutter 中使用 SingleChildScollView 时无法滚动屏幕

[英]I can't Scroll my Screen when using SingleChildScollView in flutter

我正在尝试使用 SingleChildScrollView 使我的主屏幕可滚动,但它没有按预期工作

这是我的代码:

SingleChildScrollView(
          child: Column(
            children: [
            Row(...),
              Container(
                child: Column(
                  children: [
                    Text(...),
                    SizedBox(
                      child: ListView.builder(
                        scrollDirection: Axis.vertical,
                        shrinkWrap: true,
                        itemBuilder: (context, count) {
                          return Container(
                            height: 300,
                            child: Text("hi there $count"),
                          );
                        },
                        itemCount: 4,
                      ),
                    )
                  ],
                ),
              )
            ],
          ),
        );
     

将列更改为list view

像这样

SingleChildScrollView(
          child: Column(
            children: [
            Row(...),
              Container(
                child: ListView(
                  children: [
                    Text(...),
                    SizedBox(
                      child: ListView.builder(
                        scrollDirection: Axis.vertical,
                        shrinkWrap: true,
                        itemBuilder: (context, count) {
                          return Container(
                            height: 300,
                            child: Text("hi there $count"),
                          );
                        },
                        itemCount: 4,
                      ),
                    )
                  ],
                ),
              )
            ],
          ),
        );

试试这个代码

暂无
暂无

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

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