fix: properly show the number of cards with respect to the numberOfCards param
This commit is contained in:
parent
b2dd0e001f
commit
2a6f91ef8c
|
|
@ -230,9 +230,7 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return _frontItem(constraints);
|
return _frontItem(constraints);
|
||||||
}
|
}
|
||||||
if (index == 1) {
|
|
||||||
return _secondItem(constraints);
|
|
||||||
}
|
|
||||||
return _backItem(constraints, index);
|
return _backItem(constraints, index);
|
||||||
}).reversed.toList(),
|
}).reversed.toList(),
|
||||||
);
|
);
|
||||||
|
|
@ -289,32 +287,15 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _secondItem(BoxConstraints constraints) {
|
|
||||||
return Positioned(
|
|
||||||
top: _cardAnimation.difference.dy,
|
|
||||||
left: _cardAnimation.difference.dx,
|
|
||||||
child: Transform.scale(
|
|
||||||
scale: _cardAnimation.scale,
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: constraints,
|
|
||||||
child: widget.cardBuilder(context, _nextIndex!),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _backItem(BoxConstraints constraints, int offset) {
|
Widget _backItem(BoxConstraints constraints, int offset) {
|
||||||
return Positioned(
|
return Positioned(
|
||||||
top: widget.backCardOffset.dy,
|
top: _cardAnimation.difference.dy * offset,
|
||||||
left: widget.backCardOffset.dx,
|
left: _cardAnimation.difference.dx * offset,
|
||||||
child: Transform.scale(
|
child: Transform.scale(
|
||||||
scale: widget.scale,
|
scale: _cardAnimation.scale - ((1 - widget.scale) * (offset - 1)),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: constraints,
|
constraints: constraints,
|
||||||
child: widget.cardBuilder(
|
child: widget.cardBuilder(context, getValidIndexOffset(offset)!),
|
||||||
context,
|
|
||||||
getValidIndexOffset(offset)!,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue