簡體   English   中英

如何將 Listview.builder 放在列中,以便可以在其上放置另一個小部件?

[英]How do i put a Listview.builder in a column so i can put another widget on top of it?

在此處輸入圖像描述

下面是顯示餐廳列表視圖的頁面的屏幕截圖,我想在它的 p 上放置一個文本小部件和搜索欄,但是當我將它放在列中時出現錯誤

您可以使用以下內容:

YourSearchBar(),
Expanded(
  child: ListView()
)

您可以簡單地將列表視圖包裝在單子滾動視圖中的列和列中,並將列表視圖的物理設置為 NeverScrollableScrollPhysics。

代碼:-

SingleChildScrollView(
        child: Column(
          children: <Widget>[
             YourSearchBar(),
             Text('your text'),
             ListView.builder(
                physics: NeverScrollableScrollPhysics(),
                shrinkWrap: true,
                itemCount:10,//replace 10 with the count of elements in list
                itemBuilder: (context,index){
                  return  yourWidget();//return here the widget you want to show(your cake design one)
                })
          ],
        ),
      ),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM