Skip to content
forked from Purvik/SwipeTo

SwipeTo is a wrapper for a chat view widget which can be used initiate callback when user horizontally swipe on it.

License

Notifications You must be signed in to change notification settings

raviganwal/SwipeTo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swipe_to

SwipeTo is a wrapper for a chat view widget which can be used initiate callback when user horizontally swipe on it.

Getting Started

To use this packages, you just simply need to wrap your child component in SwipeTo widget and pass a VoidCallback that you can carry forward with your task.

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  swipe_to: 0.0.1+3

In your library add the following import:

import 'package:swipe_to/swipe_to.dart';

Parameter Info

  • child : (@required) StateLess or StateFull flutter widget.
  • callBack : (@required) callback which will be initiated at the end of swipe animation
  • swipeDirection : Enum value from [swipeToLeft, swipeToRight] only. Make sure to pass relative Offset value according to passed swipeDirection value. If not specified swipeToRight will be taken as default
  • animationDuration : Duration value to define animation duration. if not specidifed default is 150 milliseconds
  • iconData : IconData that will be displayed beneath child widget. if not specified default is Icons.reply
  • iconSize : double value defining size of displayed icon beneath child widget. if not specified default it will take 26
  • iconColor : color value defining color of displayed icon beneath child widget. if not specified primaryColor from theme will be taken
  • endOffset : Offset value till which position of child widget will get animated. if not specified Offset(0.3, 0.0) default will be taken

Wrap your desired widget with SwipeTo. Example : SwipeToRight

SwipeTo(
    swipeDirection: SwipeDirection.swipeToRight,
    endOffset: Offset(0.3, 0.0),
    child: Container(
        padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0),
        child: Text('Hey You! Swipe me right 👉🏿'),
    ),
    callBack: () {
        print('Callback from Swipe To Right');
    },
),

Example : SwipeToLeft

SwipeTo(
    swipeDirection: SwipeDirection.swipeToLeft,
    endOffset: Offset(-0.3, 0.0),
    child: Container(
        padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0),
        child: Text('👈🏿 Hey You! Swipe me Left'),
    ),
    callBack: () {
        print('Callback from Swipe To Left');
    },
),

Sample Outputs

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

About

SwipeTo is a wrapper for a chat view widget which can be used initiate callback when user horizontally swipe on it.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 95.5%
  • Swift 3.2%
  • Other 1.3%