From e70b6e77bc022f8007c91f725d9fd63d8cab8ca5 Mon Sep 17 00:00:00 2001 From: Ricardo Dalarme Date: Thu, 12 Jan 2023 21:44:47 -0300 Subject: [PATCH] chore(docs): update readme --- README.md | 93 +++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 08e1616..d8e4526 100644 --- a/README.md +++ b/README.md @@ -1,67 +1,66 @@ # swipeable_cards_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.** +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_cards_stack` to your `pubspec.yaml`: -``` +```yaml dependencies: - flutter: - sdk: flutter - - # added below swipeable_cards_stack: ``` -### Adding to app + +### Usage + Use the `SwipeableCardsStack` widget provided by the package -``` -@override +```dart +import 'package:swipeable_cards_stack/swipeable_cards_stack.dart'; + +class MyWidget extends StatefulWidget { + @override + State createState() => _MyWidgetState(); +} + +class _MyWidgetState extends State { + final _cardsController = SwipeableCardsStackController(); + + @override Widget build(BuildContext context) { - //create a SwipeableCardsStackController - SwipeableCardsStackController _cardController = SwipeableCardsStackController(); + return SwipeableCardsStack( + cardController: _cardsController, + 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 + _cardsController.addItem(CardView(text: "Next card")); - return Scaffold( - appBar: AppBar( - title: Text(widget.title), - ), - body: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SwipeableCardsStack( - 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 - ) - } - + // Take action on the swiped widget based on the direction of swipe + // Return false to not animate cards + }, + enableSwipeUp: true, + enableSwipeDown: false, + ); + } +} ``` -### Author -[**CodeToArt Technology**](https://github.com/codetoart) +### Contributing -- Follow us on **Twitter**: [**@codetoart**](https://twitter.com/codetoart) -- Contact us on **Website**: [**codetoart**](http://www.codetoart.com) +If you want to contribute to this project, you may easily create issues and send PRs. Please take note that your code contributions will be applicable under MIT license unless specified otherwise. + +### Credits + +- **Ricardo Dalarme** (Package maintainer) +- [**CodeToArt Technology**](https://github.com/codetoart) (Original project creator)