【问题标题】:I can't Scroll my Screen when using SingleChildScollView in flutter在颤动中使用 SingleChildScollView 时我无法滚动屏幕
【发布时间】:2022-01-02 03:55:57
【问题描述】:

我正在尝试使用 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包装

标签: android flutter flutter-layout flutter-android flutter-scrollbar


【解决方案1】:

将列更改为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,
                      ),
                    )
                  ],
                ),
              )
            ],
          ),
        );

试试这个代码

【讨论】:

    猜你喜欢
    • 2021-11-29
    • 2020-02-08
    • 2019-12-29
    • 2021-07-05
    • 1970-01-01
    • 2019-07-30
    • 1970-01-01
    • 2020-12-24
    • 2022-01-25
    相关资源
    最近更新 更多