【问题标题】:How do i put a Listview.builder in a column so i can put another widget on top of it?如何将 Listview.builder 放在列中,以便可以在其上放置另一个小部件?
【发布时间】:2021-05-09 18:36:52
【问题描述】:

下面是显示餐厅列表视图的页面的屏幕截图,我想在其中的 p 上放置一个文本小部件和搜索栏,但是当我将它放在列中时出现错误

【问题讨论】:

  • 发布您的代码和错误
  • 用 Expanded 包裹 ListView。

标签: flutter dart frontend firebase-storage


【解决方案1】:

您可以使用以下内容:

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

【讨论】:

    【解决方案2】:

    您可以简单地将列表视图包装在单子滚动视图中的列和列中,并将列表视图的物理设置为 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)
                    })
              ],
            ),
          ),
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-18
      • 2019-01-30
      • 2021-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      相关资源
      最近更新 更多