搜索插件、代码仓与 APP 分类

swipeable_card_stack 封面
插件详情v0.0.5

swipeable_card_stack

这是一个类似 Tinder 的可滑动卡片包。您可以向堆栈中添加自己的小部件,接收所有四个方向的事件:左、右、上和下。您可以为每个方向定义自己的业务逻辑。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
216
喜欢数
106
Pub 分数
115

安装插件

flutter pub add swipeable_card_stack

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,可实现类似 Tinder 的可滑动卡片堆叠功能,允许开发者使用自己的小部件自定义卡片。它支持左、右、上、下四个滑动方向,并为每个方向提供事件回调,从而实现每种方向的自定义业务逻辑。非常适合需要交互式卡片导航的应用程序,例如约会应用或内容发现界面。该包具有跨平台特性,可在 Android、iOS、Web、macOS、Windows 和 Linux 上运行。

适合场景

  • 约会应用界面
  • 内容发现功能
  • 互动产品展示
  • 用户偏好收集
  • 游戏化用户互动
  • 基于滑动的导航

主要特点

  • 可自定义的卡片小部件
  • 四向滑动事件
  • 每滑动一次可扩展的业务逻辑
  • 跨平台支持
  • 流畅的动画过渡
  • 通过 pub.dev 实现轻松集成

适合对象

  • 开发类似 Tinder 的应用的开发者
  • 需要交互式卡片UI的设计师
  • 需要手势驱动用户流程的项目
  • 带有滑动交互的移动和网络应用
  • 原型设计交互式卡片体验

使用建议

  • 需要处理滑动逻辑的状态管理
  • 可能需要额外的样式来处理复杂的卡片设计
  • 大型卡堆的性能影响
  • 内置自定义功能有限,仅限于滑动方向
  • 依赖外部动画库以实现高级效果

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

swipeable_card_stack

This is Tinder like swipeable cards package. You can add your own widgets to the stack, receive all four events, left, right, up and down. You can define your own business logic for each direction.

Demo

Documentation

Installation

Add swipeable_card_stack to your pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter

  # added below
  swipeable_card_stack: <latest version>
Adding to app

Use the SwipeableCardsSection widget provided by the package

@override
  Widget build(BuildContext context) {
    //create a SwipeableCardSectionController
    SwipeableCardSectionController _cardController = SwipeableCardSectionController();

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          SwipeableCardsSection(
            cardController: _cardController,
            context: context,
            //add the first 3 cards (widgets)
            items: [
              CardView(text: "First card"),
              CardView(text: "Second card"),
              CardView(text: "Third card"),
            ],
            //Get card swipe event callbacks
            onCardSwiped: (dir, index, widget) {
              //Add the next card using _cardController
              _cardController.addItem(CardView(text: "Next card"));
              
              //Take action on the swiped widget based on the direction of swipe
              //Return false to not animate cards
            },
            //
            enableSwipeUp: true,
            enableSwipeDown: false,
          ),
          //other children
        )
    }
          
Author

CodeToArt Technology

所属分类

源码仓库

使用此插件的项目