Skip to main content

flip_card_swiper 2.2.0 copy "flip_card_swiper: ^2.2.0" to clipboard
flip_card_swiper: ^2.2.0 copied to clipboard

A customizable, swipeable card widget with smooth flip animations and haptic support.

Flip Card Swiper

Swipeable cards with flip animations, optional haptics, and a simple API.


Platform Pub Package CI License: MIT Donate


Features • Installation • Usage • Changelog • License • Bugs or Requests



3D Edge Demo Credit Card Demo Minimal Demo
3D Edge Flip Effect Credit Card Style Minimal Style

Features #

  • Flip and swipe:
    Drag up to flip the top card. Motion eases in and out; the second half of the flip stays smooth instead of feeling mushy at the end. After you pass halfway, how long the finish takes depends on how fast you flicked and on completionPhaseScale. You can also change animationDuration, thresholdValue (progress along the drag-past this, releasing can finish the flip even before the halfway point), maxDragDistance, and optional earlyLiftBoost / rotationStartFraction for extra lift at the start of the drag.

  • Gestures that always resolve:
    When you lift your finger, the flip either completes or springs back-you should not get stuck between the two after a partial swipe. One drag flips at most one card, a quick flick flips even before thresholdValue, and a swipe started while the previous flip is finishing is never dropped. Pulling down rubber-bands toward dragDownLimit.

  • Haptics:
    Light feedback while cards move. Turn it off with enableHaptics: false.

  • Accessibility and keyboard:
    Screen readers announce the position ("2 of 5") and can flip with the increase / scroll-up action; cards hidden underneath are not read. Touch the stack and press ↑ to flip from a keyboard. Optional semanticsLabel / semanticsHint, and the platform’s reduce motion setting (MediaQuery.disableAnimations) is respected.

  • Reordering:
    Cards swap order halfway through the flip so you can loop through a list without a hard cut. The next card slides out from behind the deck as the flipped card tucks in, and cards keep their State while they are visible-so stateful, themed or image cards just work.

  • Layout:
    Separate scale and offset for the top three cards so you can tune the stack look.

No extra dependencies or complicated setup-just integrate and start flipping!


Installation #

Add this under dependencies in pubspec.yaml:

dependencies:
  flip_card_swiper: ^2.2.0

Fetch packages:

flutter pub get

Usage #

import 'package:flutter/material.dart';
import 'package:flip_card_swiper/flip_card_swiper.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  final List<Map<String, dynamic>> cards = [
    {'color': Colors.blue, 'text': 'Card 1'},
    {'color': Colors.red, 'text': 'Card 2'},
    {'color': Colors.green, 'text': 'Card 3'},
  ];

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: FlipCardSwiper(
            cardData: cards,
            onCardChange: (newIndex) {
              // Runs when the top card changes after a flip.
            },
            // completionPhaseScale: 1.35,  // optional: longer second half
            // animationDuration: const Duration(milliseconds: 600),  // default
            cardBuilder: (context, index, visibleIndex) {
              final card = cards[index];
              // Use the data index (or another stable id) as the key so state
              // survives when cards move in the stack-not only visibleIndex.
              return Container(
                key: ValueKey(index),
                width: 300,
                height: 200,
                decoration: BoxDecoration(
                  color: card['color'],
                  borderRadius: BorderRadius.circular(12),
                ),
                alignment: Alignment.center,
                child: Text(
                  card['text'],
                  style: const TextStyle(fontSize: 24, color: Colors.white),
                ),
              );
            },
          ),
        ),
      ),
    );
  }
}


Example and tests #

The example app has six styles (basic, credit cards, tap-to-reveal flash cards, travel, profiles, minimal news) with a card counter driven by onCardChange.

flutter test                                   # package tests
cd example && flutter test integration_test -d <simulator-id>   # e2e on a device or simulator

The e2e suite drives every example (slow drags, flings, flicks, cancels, pull-down, rapid swipes, wrap-around, keyboard, screen reader) and prints METRIC lines with latency and frame timings.

Changelog #

See CHANGELOG.md for version history.

License #

MIT License

Copyright (c) 2024 Abhay Maurya

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Bugs or Requests #

77
likes
160
points
972
downloads
screenshot

Documentation

API reference

Publisher

verified publisherhashstudios.dev

Weekly Downloads

A customizable, swipeable card widget with smooth flip animations and haptic support.

Repository (GitHub)
View/report issues

Topics

#animation #card #swipe #transform #flip

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flip_card_swiper