SwipeCard constructor
SwipeCard({
- required CardBuilder cardBuilder,
- required int totalNum,
- AmassOrientation orientation = AmassOrientation.LEFT,
- int stackNum = 3,
- int animDuration = 800,
- double swipeEdge = 3.0,
- double swipeEdgeVertical = 8.0,
- double? maxWidth,
- double? maxHeight,
- double? minWidth,
- double? minHeight,
- bool allowVerticalMovement = true,
- required CardController cardController,
- required CardSwipeCompleteCallback swipeCompleteCallback,
- required CardDragUpdateCallback swipeUpdateCallback,
Constructor requires Card Widget Builder cardBuilder
& your card count totalNum
, option includes: stack orientation orientation
, number of card display in same time stackNum
, swipeEdge
is the edge to determine action(recover or swipe) when you release your swiping card
it is the value of alignment, 0.0 means middle, so it need bigger than zero.
, and size control params;
Implementation
SwipeCard(
{required CardBuilder cardBuilder,
required int totalNum,
AmassOrientation orientation = AmassOrientation.LEFT,
int stackNum = 3,
int animDuration = 800,
double swipeEdge = 3.0,
double swipeEdgeVertical = 8.0,
double? maxWidth,
double? maxHeight,
double? minWidth,
double? minHeight,
bool allowVerticalMovement = true,
required this.cardController,
required this.swipeCompleteCallback,
required this.swipeUpdateCallback})
: this._cardBuilder = cardBuilder,
this._totalNum = totalNum,
assert(stackNum > 1),
this._stackNum = stackNum,
this._animDuration = animDuration,
assert(swipeEdge > 0),
this._swipeEdge = swipeEdge,
assert(swipeEdgeVertical > 0),
assert(maxWidth! > minWidth! && maxHeight! > minHeight!),
this._allowVerticalMovement = allowVerticalMovement {
double widthGap = maxWidth! - minWidth!;
double heightGap = maxHeight! - minHeight!;
swipeAligns = [];
swipeSize = [];
for (int i = 0; i < _stackNum; i++) {
swipeSize.add(new Size(minWidth + (widthGap / _stackNum) * i,
minHeight + (heightGap / _stackNum) * i));
switch (orientation) {
case AmassOrientation.LEFT:
swipeAligns.add(
new Alignment((-0.5 / (_stackNum - 1)) * (stackNum - i), 0.0));
break;
case AmassOrientation.RIGHT:
swipeAligns.add(
new Alignment((0.5 / (_stackNum - 1)) * (stackNum - i), 0.0));
break;
}
}
}