swipe_stack

Swipe stack flutter.

Screenshot

Youtube Video

Installation

Add

swipe_stack : ^latest_version

to your pubspec.yaml.

Usage

ParameterDefaultDescription
maxAngle35Maximum rotation value. Must be int between 0 and 360
threshold30Manual swipe is canceled when the card is dragged less than threshold. Must be int between 1 and 100
stackFromStackFrom.NoneStack type. Must be one of StackFrom.Left, StackFrom.Right, StackFrom.Top, StackFrom.Bottom, StackFrom.None
visibleCount2Number of objects to display. Must int and at least 2
translationInterval0Distance between objects. Must be positive integer
scaleInterval0Decreasing scale value. Must be positive double
animationDurationDuration(milliseconds: 200)Animation duration
historyCount1Number of objects to keep in the history. Must be positive integer
paddingEdgeInsets.symmetric(vertical: 20, horizontal: 25)Main container padding
SwipeStack(
    children: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((int index) {
        return SwiperItem(
            builder: (SwiperPosition position, double progress) {
                return Material(
                    elevation: 4,
                    borderRadius: BorderRadius.all(Radius.circular(6)),
                    child: Container(
                        decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.all(Radius.circular(6)),
                        ),
                        child: Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: <Widget>[
                                Text("Item $index", style: TextStyle(color: Colors.black, fontSize: 20)),
                                Text("Progress $progress", style: TextStyle(color: Colors.blue, fontSize: 12)),
                            ],
                        )
                    )
                );
            }
        );
    }).toList(),
    visibleCount: 3,
    stackFrom: StackFrom.Top,
    translationInterval: 6,
    scaleInterval: 0.03,
    onEnd: () => debugPrint("onEnd"),
    onSwipe: (int index, SwiperPosition position) => debugPrint("onSwipe $index $position"),
    onRewind: (int index, SwiperPosition position) => debugPrint("onRewind $index $position"),
)

Manuel Usage

final GlobalKey<SwipeStackState> _swipeKey = GlobalKey<SwipeStackState>();
SwipeStack(
    key: _swipeKey,
    ...,
)
_swipeKey.currentState.swipeLeft();
_swipeKey.currentState.swipeRight();
_swipeKey.currentState.rewind();

Libraries

swipe_stack