搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。