簡體   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