【问题标题】:Flutter ListView.builder sizedbox problemFlutter ListView.builder sizedbox问题
【发布时间】:2021-12-14 20:56:48
【问题描述】:

当我尝试向下滚动查看整个文本时,我无法向下滚动。我认为问题出在 sizebox 的高度上。

我使用sizedbox,因为如果我不使用上面的listview builder,那么它不会显示任何内容。

代码:

Column(
children: [
           SizedBox(
           height: MediaQuery.of(context).size.height,
           width: MediaQuery.of(context).size.width,
           child: ListView.builder(
           shrinkWrap: true,
           itemCount:
           snapshotPosts.data?.data()!["random"]?.length,
           itemBuilder: (context, index) {..})...

【问题讨论】:

  • 您可以使用Expanded 而不是SizedBox,因为它是Column 的子代。
  • @esentis 我试过了,但是因为没有高度,所以不行

标签: flutter listview flutter-layout


【解决方案1】:

我没有在网络上找到任何东西,但我解决了这样的问题: 我删除了 Sizedbox,然后放了卡片而不是 sizedbox。 这当然是不够的。我还删除了第二个 futureBuilder。

【讨论】:

    【解决方案2】:

    在你使用过的第一个 SizedBox 之后,可以添加其他没有子的 SizedBox,例如:

    SizedBox(
     height: 50,
    ),
    

    或者为了响应任何屏幕,你可以使用这个:

    SizedBox(
    height: MediaQuery.of(context).size.height * 0.1,
    ),
    

    通过这种方式,您可以添加空白区域以查看上面的 Widgets。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-20
      • 1970-01-01
      • 2018-10-25
      • 2022-01-18
      • 1970-01-01
      • 2020-09-18
      • 2020-01-02
      • 1970-01-01
      相关资源
      最近更新 更多