Code Monkey home page Code Monkey logo

flutter_card_swiper's Introduction

Hi there, I'm Ricardo Dalarme 👋

I'm a Software Developer at ProFusion.

  • ‍💻 I've been working for more than 2 years in software development
  • 👯 I've experience with React, Flutter, Android, iOS, Node, TypeScript, GraphQL and more!
  • 🎮 I've an Never Have I Ever game published on the PlayStore
  • 🤖 I make combat robots
  • ⚡ Fun fact: When I was a child I created a game engine

Packages I maintain

Connect with me:

Linkedin Badge Instagram Badge

flutter_card_swiper's People

Contributors

andrea689 avatar giboin avatar husainazkas avatar jawwad-hassan89 avatar kal-elx avatar kzrnm avatar ricardodalarme avatar richertc avatar sarope 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  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  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  avatar  avatar  avatar  avatar

Watchers

 avatar

flutter_card_swiper's Issues

Add overlay builder with direction and progress

Hello, appreciate your work with this package, especially considering that Appinio Swiper is basically abandoned. I was wondered if it would be possible to add an overlay builder, so that it would be possible to create animated overlays, like Tinder which displays a "Like" or "Nope" text in the corner, when the user swipes (see https://www.virtuallocation.com/images/tinder/tinder-swipe-3.jpg).

Ideally this builder would be a method, that gives the direction the user has swiped, as well as the progress of how fair they've swiped the card from the center. The method would return a widget, that would be drawn ontop of the top card (the one being dragged). The progress would be used to fade in or out the overlay depending on how far the user drags the card, and the direction would be used for showing different overlays, depending on which direction the user drags the card.

The package swipable_stack has this feature, if that is of any help: https://pub.dev/packages/swipable_stack

Thanks again for your work, this package definitely seems like the best and most elegant swipe solution for Flutter.

Unable to import the package

Hey !

I can't import this package in my project ...

I've added flutter_card_swiper: ^5.0.0 inside the dependencies in my projet's pubspec.yalm file.

And when I try to import the package in my DART file (import 'package:flutter_card_swiper/flutter_card_swiper.dart';) it says : Target of URI doesn't exist: 'package:flutter_card_swiper/flutter_card_swiper.dart'.
Try creating the file referenced by the URI, or try using a URI for a file that does exist.darturi_does_not_exist.

Any idea how to solve it ?

OnSwipe always showing the Next Card

Is it possible to show the previous Card on SwipeDown or Swipe left. The example application is always showing the next Card on whatever direction you swipe. The undo button works as expected but I can not do it on swipe.

I tried this way

bool _onSwipe(
    int previousIndex,
    int? currentIndex,
    CardSwiperDirection direction,
  ) {
    if (direction.name == 'left') {
      debugPrint(
          'The card $previousIndex was swiped to the ${direction.name}. Now the card $currentIndex is on top');
    } else if (direction.name == 'right') {
      debugPrint(
          'The card $previousIndex was swiped to the ${direction.name}. Now the card $currentIndex is on top');
    } else if (direction.name == 'top') {
      debugPrint(
          'The card $previousIndex was swiped to the ${direction.name}. Now the card $currentIndex is on top');
    } else if (direction.name == 'bottom') {
      controller.undo();
      bool h = _onUndo(previousIndex - 1, currentIndex!, direction);
      debugPrint(
          '$h The card $previousIndex was swiped to the ${direction.name}. Now the card $currentIndex is on top');
    } else {
      debugPrint(
          'The card $previousIndex was swiped to the ${direction.name}. Now the card $currentIndex is on top');
    }

    return true;
  }

Set swipe like and nope image like tinder

Does this package provide any functionality to set the image when the user swipes right/left on the card, similar to a Tinder swipe?
I tried using "onSwipeDirectionChange" but wasn't able to, so how can we achieve it, or is there any functionality available on this package?

add the possibility to disable some swipe directions

I would like to restrain the possible swipe directions to left and right only

I will try to work on it and hopefully submit a PR in the next few days but it would be my first time really contributing to an open source project, so I might need some help about good practices...

Use with FirestoreQueryBuilder

First of all, nice package!

Trying to use this together with the FirestoreQueryBuilder to create a dynamic stack of cards streamed from a Firestore database. This setup works very well when combined with ListView, PageView or GridView, or any other builder that does infinite scrolling. The issue is that this widget removes cards and the FirestoreQueryBuilder also automatically rebuilds since the contents of the stream has changed due to the onSwipe callback and when new records are created in the database by other users. When I set the onSwipe result to false this is solved and it works, except...

The only thing is that the rebuild makes the focus card flicker for an instant, I don't see an easy way to remedy this. The entire CardSwiper widget rebuilds. The flickering shows the previous card for an instant. So you see the correct card from the background being animated to the front, then the previous card flickering, and then the correct front card again.

return FirestoreQueryBuilder<UserTask>(
      query: UserTask.unreadForQuery(user.id),
      pageSize: 5,
      builder: (context, snapshot, _) {
        if (snapshot.isFetching) {
          return SizedBox.shrink();
        }

        if (snapshot.hasData && snapshot.docs.isEmpty) {
          return SizedBox.shrink();
        }

        if (snapshot.hasError) {
          LogService.log(snapshot.error.toString());

          return SizedBox.shrink();
        }

        final focus = snapshot.docs.first.data();

        ///TODO: stop flickering due to rebuild
        return CardSwiper(
          cardBuilder: (context, index, _, __) {
            if (snapshot.hasMore && index + 1 == snapshot.docs.length) {
              snapshot.fetchMore();
            }

            return UserTaskSnapTileHome(
              userTask: snapshot.docs[index].data(),
              borderRadius: BorderRadius.circular(20),
            );
          },
          cardsCount: snapshot.docs.length,
          isLoop: false,
          padding: p12,
          numberOfCardsDisplayed: snapshot.docs.length > 1 ? 2 : 1,
          onSwipe: (previousIndex, currentIndex, direction) {
            switch (direction) {
              case CardSwiperDirection.right:
                focus.removeStatus([UserTaskStatus.unread]);
                break;
              case CardSwiperDirection.left:
                focus.removeStatus([UserTaskStatus.unread]);
                break;
              case CardSwiperDirection.top:
                focus.removeStatus([UserTaskStatus.unread]);
                break;
              default:
                break;
            }

            return false;
          },
        );
      },
    );

Do you have any suggestions?

Cards Flickering

Swipe cards flicker when there is a future builder in the child of the card.

Possibility to get index of card through controller

I can create buttons that interact with the card swiper widget but i can't create a button that gets the index of the card and lets you get the card information from that index.
Is it already possible to do so with the controller without using external variables?

Enable to swipe within a PageView/TabBarView

Hello,

I have a CardSwiper inside my TabBarView that as the isVerticalSwipingEnabled property to false. The problem is that if I try to move horizontally my cards, it will trigger the scroll of the TabView and not the CardSwiper.

I tried to replace in the CardSwiper widget the onPanStart/onPanUpdate/onPanEnd by onHorizontalDragStart/onHorizontalDragUpdate/onHorizontalDragEnd, it works but I don't know if it is the correct way to fix it. Can you check it ? Thanks

Customizing back card offset position

So I recently started using this package, pretty neat!! However I have a use case where the card is positioned exactly on top of each other (so kinda like a stack of cards where the 2nd card is covered completely with the 1st card). Looking at the docs, there's no option to customize the back card offset position, is there anyway to do this?

Adding new cards to the stack on-the-fly

Came from https://github.com/appinioGmbH/flutter_packages and stumbled upon your package here, and reviewed a bit of your code. Looks like some decent improvements!

I like that you added internal state of cards - as well as seperated the package into it's own, which it deserves - however, do you have any working examples of adding new cards to the stack? E.g. when there's 3 items left in stack, add in more?

Request for adding a function: determining the start of card movement

Hello! I really like your package flutter_card_swiper, it almost meets my needs. I would like to know how I can get the card offset coordinate? I'll take a picture. The onSwipe event shows the final direction after moving the card, as does the onSwipeDirectionChange event. I would like to be able to determine the beginning of the movement and the direction, perhaps get the X and Y coordinates. It is important for me to know the moment the movement begins, the direction in which direction the movement is carried out and the end of the movement when the card is flipped. Please tell me, is it possible to somehow find out this now or is there such functionality in the plans?

Controller swipeLeft/Right angle

The controller can currently swipeLeft and swipeRight, however this loses the beautiful part of the angle that the card tilts away at when swiping with your thumb across the card.

Is there any plan to support the angle by which the controller moves the top card away to the left or right?

strange when page can scroll

if the page can be scroll:when scroll pre page,then swipe to next page; the next page will scroll to pre page's position,it looks very strange

Undo feature

I would like to have a method like undo in CardSwiperController

Can we change height and width of cards

Hello,
I am using this plugin and it is awesome, but the cards are of default width and height now my requirement is to give proper height, I managed that somehow by wrapping in SizedBox but I can't change the width I want to give the width to fit screen
Can anyone help?
Thanks

image

Container(
                    height: 234.h,
                    width: 1.sw,
                    color: Colors.amber,
                    child: CardSwiper(
                    cardsCount: newsList.length,
                    numberOfCardsDisplayed: 3,
                    backCardOffset: Offset(0, 20.h),
                    padding: EdgeInsets.zero,
                      cardBuilder: (BuildContext context, int index, _, __) {
                      return ItemLatestPostCard(item: newsList[index]);
                    },
                    ),
                  ),

Vertical swipe sensitivity

Hi, thanks for the great work on this package, it's been working great thus far! One issue I have noticed however is that often when swiping a card upwards following the natural arc'ed gesture of the thumb, swipes are incorrectly categorized as a Left or Right swipe rather than an upwards swipe.

Steps to reproduce:

  1. Create a basic CardSwiper that allows both horizontal and vertical swipe directions
  2. For the onSwipe parameter, add a simple print to display the swipe direction
    print('$previousIndex, $currentIndex, $direction');
  3. Swipe card upwards, initially starting with a straight vertical motion, progressively increasing the angle of the swipe

onSwipe returns wrong resulting index

After checking closely I see that the onSwipe index after first crd swipe is still 0, and all following swipes return lower values.
This may happen because the widget.onSwipe?.call(_currentIndex, detectedDirection); called BEFORE the index is updated, not AFTER.

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.