GitHub 代码仓jushutch/swiping_card_deck

swiping_card_deck

一个用于通过手势或按钮滑动浏览卡片堆的控件。

swiping_card_deck 项目封面
星标
13
复刻
12
最近推送(UTC)
2023年9月9日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

swiping_card_deck

Flutter Tests Test Coverage Bugs

A widget for swiping through a deck of cards with gestures or buttons.

This package was inspired when I was trying to develop a Tinder-like app that involved swiping options to the left or right. I assumed that a package existed for such a popular functionality, but I searched the internet and could only find bits and pieces of different implementations that were confusing, complicated, and down right bad. This package aims to be an easy-to-use and customizable way to implement that functionality, and will hopefully save you a great amount of time!

SwipingCardDeck Demonstration

Features

The SwipingCardDeck widget offers a variety of unique features:

  • Swipe through cards by dragging or using buttons to hook into the public swipeLeft and swipeRight functions.
  • Provide custom callback functions for when the deck is empty and for each swiping direction, which also pass in the original Card object.
  • Use custom Cards of any shape, size, or content.
  • Optimized performance by rendering top two cards at a time, allowing for large decks with no decrease in user experience.
  • A variety of exposed properties allow for a swiping experience that can be designed for any need.
  • Great for any Tinder-like decision making application.

To create a deck of any widget, use the generic SwipingDeck class with templating!

What this package doesn't support:

  • Vertical swiping

Usage

Constructing a SwipingCardDeck with two cards and two buttons that can be used for swiping. Callback functions print out debugging information. The parameters minimumVelocity, rotationFactor, swipeThreshold, and swipeAnimationDuration are all optional, but are set to the default values which work well for most use cases. The disableDragging parameter is set to false by default, but can be set to true in order to prevent cards from being swiped using the dragging gesture.

SwipingCardDeck(
    cardDeck: <Card>[
        Card(
            color: Colors.red,
            child: const SizedBox(height: 300, width: 200,)
        ),
        Card(
            color: Colors.green,
            child: const SizedBox(height: 300, width: 200,)
        ),
    ],
    onDeckEmpty: () => debugPrint("Card deck empty"),
    onLeftSwipe: (Card card) => debugPrint("Swiped left!"),
    onRightSwipe: (Card card) => debugPrint("Swiped right!"),
    swipeThreshold: MediaQuery.of(context).size.width / 4,
    minimumVelocity: 1000,
    cardWidth: 200,
    rotationFactor: 0.8 / 3.14,
    swipeAnimationDuration: const Duration(milliseconds: 500),
    disableDragging: false,
);

Additional information

Issues and suggestions

This package is being actively maintained and developed. To submit ideas, issues, or suggestions, create an issue in the GitHub repository.

Contributing

Thank you for your interest in contributing! To get started, read through the documentation in CONTRIBUTING. There are always new issues coming so be sure to check back often, and if there's something you want to work on but there's no issue, just open one yourself!

Justin Hutchins GitHub avatar
GitHub 作者

Justin Hutchins ↗

University of Michigan, Ann Arbor - Computer Science B.S. 2022

语言Dart

分类

此仓库发布的插件

使用的依赖

依赖清单 3 项

  • flutter{"sdk":"flutter"}
  • flutter_test开发依赖{"sdk":"flutter"}
  • flutter_lints开发依赖>=1.0.0 <3.0.0

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗