Code Monkey home page Code Monkey logo

cta-flutter-tinder-card-animation's Introduction

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

cta-flutter-tinder-card-animation's People

Contributors

asgalex avatar l3odr0id avatar mahavir155 avatar supermuesli avatar tusharghatwal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cta-flutter-tinder-card-animation's Issues

Cancel swipe in onCardSwiped

Hello! Beautiful project, it works brilliantly! Is there currently an idiomatic way to "cancel" the swipe? i.e. the user swipes up, the card returns to its position on the top of the stack, and other action happens.

Thank you!

Cards don't update on outside state changes

Consider this simple page: a counter, a button that increments the counter, and two Text widgets displaying the count: one inside SwipeableCardsSection, one outside.

import 'package:flutter/material.dart';
import 'package:swipe/card_view.dart';
import 'package:swipeable_card_stack/swipeable_card_stack.dart';

void main() {
  runApp(const MaterialApp(
    home: MyHomePage(),
  ));
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int counter = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          ElevatedButton(
            child: const Text('Increment'),
            onPressed: () => setState(() {
              counter++;
            }),
          ),
          Text("Counter (outside swipeable): $counter"),
          SwipeableCardsSection(
            cardController: SwipeableCardSectionController(),
            context: context,
            items: [
              Text("Counter (inside swipeable): $counter"),
            ],
            enableSwipeUp: true,
            enableSwipeDown: true,
          ),
        ],
      ),
    );
  }
}

Expected behavior: both text widgets show the count.
Actual behavior: the widget outside SwipeableCardsSection updates, the inside widget doesn't.

Screen Shot 2022-12-19 at 8 22 01 PM

Weird Widget

I wanted to add a stacked swipeable card widget to my project, but this widget isn't working.
It seems i cannot set the card width or heigth, but i need to set the cardWidthTopMul (i can imagine what it is) but it destroys the sensibility while dragging.
I am using this on a web application, is this a bug?

Widget bodyLayout() { return Center( child: Column( children: [ SwipeableCardsSection( cardWidthTopMul: 0.2, items: _newCards, context: context, enableSwipeDown: false, enableSwipeUp: false, ), ], ), ); }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.