在flutter中不可能在列中无限滚动?

问题描述 投票:0回答:1

我使用这个无限滚动库。 https://pub.dev/packages/infinite_scroll_pagination 无限滚动分页 4.0.0 我的无限滚动位于副标题文本小部件下方! 像这样:

body: SingleChildScrollView(
    scrollDirection: Axis.vertical,
    physics: const BouncingScrollPhysics(),
    Column(
        children: [
            Text("Sub title."),
            ...
            PagedListView(
                shrinkWrap: true,
                physics: const NeverScrollableScrollPhysics(),
                pagingController: controller.pagingController,
                builderDelegate: ...
            )
        ]
    )
)

是的,它可以工作,但是工作不正常。 一次性发出所有 API 请求。我没有滚动。

删除 SingleChildScrollView 和 Column 效果很好。 但我需要副标题和所有在正文上滚动..

我希望文本和列表一起滚动,并且滚动效果很好。

我该怎么办?感谢您阅读我的问题,祝您有美好的一天!

flutter infinite-scroll flutter-column
1个回答
0
投票

PagedChildBuilderDelegate
提供来自
index
itemBuilder
,可用于仅返回第一项的 子标题

builderDelegate: PagedChildBuilderDelegate<int>(
  itemBuilder: (context, item, index) => index == 0
      ? Column(
          children: [
            Text("Sub title."),
            Text(item.toString()), //yourItemBuilder
          ],
        )
      : Text(item.toString()), //yourItemBuilder
),
© www.soinside.com 2019 - 2024. All rights reserved.