0

我正在尝试使用 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,
                      ),
                    )
                  ],
                ),
              )
            ],
          ),
        );
     
4

1 回答 1

0

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

试试这个代码

于 2022-01-02T04:16:31.490 回答