swipe_widget 0.0.1+1
swipe_widget: ^0.0.1+1 copied to clipboard
Make a Widget swipe to the sides, adding different funcionalities.
Swipe Widget #
A Flutter Widget to make your widgets swipe to the sides.
Features #
- Your widget will be draggable with a smooth animation.
- When dragging to the sides and let go, if the widget is passed a certain threshold it will swipe away.
- You can set actions for swipe, left and right, and to when the distance changes.
Getting started #
Install it using pub:
flutter pub add swipe_widget
And import the package:
import 'package:swipe_widget/swipe_widget.dart';
Usage #
It's as simple as:
SwipeWidget(
child: <your_widget>
);
If you want to add funcionalities you can add Functions:
SwipeWidget(
OnSwipe: () => print('Swiped!'),
OnSwipeLeft: () => print('Swiped left! I feel rejected...'),
OnSwipeRight: () => print('Swiped right!'),
OnUpdate: (distance) => print('The distance of the swipe is $distance (from 0 to 1)'),
child: <your_widget>
);
You can change how the swipe should react:
SwipeWidget(
distance: 0.5,
angle: 0.4,
rotation: 25,
scale: 1,
dragResistance: 0.5,
child: <your_widget>
);
- These properties are related to how far the widget is being dragged.
- Distance is the threshold needed to take action when dropping. (Examle: If it was 0.5, stop dragging while the widget is more than half of the way would be enough to trigger the full swipe)
- Angle is in radians, while rotation is in degrees. (Angle has priority)
GitHub (Gist) #
The widget code is available on Gist: Flutter - SwipeWidget