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

swipable_stack 封面
插件详情v2.0.0

swipable_stack

一个用于堆叠卡片的组件,用户可以像 Tinder 一样水平和垂直滑动,并带有精美的动画效果。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
8300
喜欢数
325
Pub 分数
150

安装插件

flutter pub add swipable_stack

插件介绍

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

一个 Flutter 小部件,可创建具有流畅水平和垂直滑动动画的交互式卡片堆栈,灵感来自 Tinder。它允许用户通过直观的手势左右(或上下)滑动卡片,并实现优雅的过渡效果。非常适合需要基于滑动界面的应用程序,例如约会应用、产品展示或内容发现功能。该包支持多个平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,确保在各种设备上行为一致。

适合场景

  • 约会应用界面
  • 产品或商品发现
  • 通过滑动手势浏览内容
  • 交互式入门流程
  • 游戏化用户参与
  • 基于滑动的测验

主要特点

  • 平滑的水平和垂直滑动
  • 可自定义的动画曲线
  • 带反馈的手势识别
  • 对多平台的支持
  • 与现有 UI 的轻松集成
  • 可配置的卡片对齐方式和间距

适合对象

  • 开发基于滑动的用户界面的开发者
  • 寻求交互式卡片体验的设计人员
  • 需要手势驱动导航的应用
  • 跨平台移动和Web应用
  • 原型设计交互式布局

使用建议

  • 可能需要对大型卡牌堆进行性能调优
  • 对复杂动画的内置自定义功能有限
  • 在快速滑动时需要仔细处理状态
  • 未针对极高频率的滑动交互进行优化
  • 最适合中等数量的卡片,以保持响应速度

原始 README

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

swipable_stack

pub.dev github likes popularity pub points license

A widget for stacking cards, which users can swipe horizontally and vertically with beautiful animations like Tinder UI.

demo

(Sorry, the package name swipable_stack is typo of swipeable stack)

Usage

builder

A SwipableStack uses a builder to display widgets.

SwipableStack(
  builder: (context, properties) {
    return Image.asset(imagePath);
  },
),

onSwipeCompleted

You can get completion event with onSwipeCompleted.

SwipableStack(
  onSwipeCompleted: (index, direction) {
    print('$index, $direction');
  },
)

overlayBuilder

You can show overlay on the front card with overlayBuilder.

SwipableStack(
  overlayBuilder: (context, properties) {
    final opacity = min(properties.swipeProgress, 1.0);
    final isRight = properties.direction == SwipeDirection.right;
    return Opacity(
      opacity: isRight ? opacity : 0,
      child: CardLabel.right(),
    );
  },
)

controller

SwipableStackController allows you to control swipe action & also rewind recent action.

final controller = SwipableStackController();

SwipableStack(
  controller:controller,
  builder: (context, properties) {
    return Image.asset(imagePath);
  },
);
controller.next(
  swipeDirection: SwipeDirection.right,
);
controller.rewind();

SwipableStackController provides to access currentIndex of SwipableStack.

final controller = SwipableStackController();
controller.addListener(() {
  print('${_controller.currentIndex}');
});

onWillMoveNext

You can also restrict user actions according to index or action with onWillMoveNext.

SwipableStack(
  onWillMoveNext: (index, direction) {
    final allowedActions = [
      SwipeDirection.right,
      SwipeDirection.left,
    ];
    return allowedActions.contains(direction);
  },
);

swipeAssistDuration

You can set the speed the user is able to swipe through Widgets with the swipeAssistDuration.

SwipableStack(
  swipeAssistDuration: Duration(milliseconds: 100),
)

The default is 650ms.

stackClipBehaviour

You can set the clipBehaviour of the stack with the stackClipBehaviour.
Change it to Clip.none to exceed the boundaries of parent widget size.

SwipableStack(
  stackClipBehaviour: Clip.none,
)

The default is Clip.hardEdge.

allowVerticalSwipe

Disable vertical swipe with allowVerticalSwipe.
Changing to false disable vertical swipe capabilities

SwipableStack(
  allowVerticalSwipe: false,
)

The default is true.

swipeTopAnchor

Set the swipe anchor with swipeAnchor with the following enum SwipeAnchor.top : card rotation on bottom and anchored on top SwipeAnchor.bottom : card rotation on top and anchored on bottom

SwipableStack(
  swipeAnchor: SwipeAnchor.top,
)

The default is SwipeAnchor.top.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。