精致流畅的卡片滚动列表组件,遵循标准的 Flutter Slivers 协议。

Screenshot

入门

只需将其作为依赖项添加到 pubspec.yaml

dependencies:
  flutter_cards_reel: any

用法

Cards Reel 小部件遵循常见的 Flutter 列表协议。

  • SliverCardsReel 实现所有低级 slivers 协议逻辑,以便它可以与 CustomScrollView 中的任何其他内容结合使用

  CustomScrollView(
    slivers: [
      SliverList(/* some other sliver */),
      SliverCardsReel(
        itemExtent: 400,
        itemHeaderExtent: 100,
        delegate: SliverChildBuilderDelegate(
          (context, index) {
            return Padding(
              padding: const EdgeInsets.all(10),
              child: SizedBox(
                height: 400,
                child: ColorfulCard(index),
              ),
            );
          },
          childCount: 4,
        ),
      ),
      SliverList(/* some other sliver */),
    ],
  )
  • CardsReelView 提供与 ListView 小部件类似的 childrenbuilder 选项的标准 API

  CardsReelView.builder(
    itemExtent: 400,
    itemHeaderExtent: 100,
    itemCount: 5,
    itemBuilder: (context, index) {
      return Padding(
        padding: const EdgeInsets.all(10),
        child: SizedBox(
          height: 400,
          child: ColorfulCard(index),
        ),
      );
    },
  )
  • CardsReelPhysics 提供简单的卡片吸附逻辑,并由 CardsReelView 小部件在内部使用

请查看 /example 文件夹以获取更多详细信息。

其他链接

GitHub

查看 Github