Skip to content

Commit b07412a

Browse files
committed
Fixes #23 (Exception with Drawer delegate when different action count)
1 parent 60ec70f commit b07412a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/src/widgets/slidable.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -547,34 +547,34 @@ class SlidableDrawerDelegate extends SlidableStackDelegate {
547547
Widget buildStackActions(BuildContext context, SlidableDelegateContext ctx) {
548548
return new Positioned.fill(
549549
child: new LayoutBuilder(builder: (context, constraints) {
550-
final count = ctx.state.actionCount;
550+
final state = ctx.state;
551+
final count = state.actionCount;
552+
final bool showActions = ctx.showActions;
553+
final Animation<double> actionsMoveAnimation =
554+
state.actionsMoveAnimation;
551555
final double actionExtent =
552-
ctx.getMaxExtent(constraints) * ctx.state.widget.actionExtentRatio;
556+
ctx.getMaxExtent(constraints) * state.widget.actionExtentRatio;
557+
final SlideActionDelegate actionDelegate = state.actionDelegate;
553558

554559
final animations = Iterable.generate(count).map((index) {
555560
return new Tween(
556561
begin: ctx.createOffset(-actionExtent),
557562
end: ctx.createOffset((count - index - 1) * actionExtent),
558-
).animate(ctx.state.actionsMoveAnimation);
563+
).animate(actionsMoveAnimation);
559564
}).toList();
560565

561566
return new AnimatedBuilder(
562-
animation: ctx.state.actionsMoveAnimation,
567+
animation: actionsMoveAnimation,
563568
builder: (context, child) {
564569
return new Stack(
565-
children: List.generate(ctx.state.actionCount, (index) {
570+
children: List.generate(count, (index) {
566571
// For the main actions we have to reverse the order if we want the last item at the bottom of the stack.
567-
int displayIndex = ctx.showActions
568-
? ctx.state.actionCount - index - 1
569-
: index;
572+
int displayIndex = showActions ? count - index - 1 : index;
570573
return ctx.createPositioned(
571574
position: ctx.getAnimationValue(animations[index]),
572575
extent: actionExtent,
573-
child: ctx.state.actionDelegate.build(
574-
context,
575-
displayIndex,
576-
ctx.state.actionsMoveAnimation,
577-
SlidableRenderingMode.slide),
576+
child: actionDelegate.build(context, displayIndex,
577+
actionsMoveAnimation, SlidableRenderingMode.slide),
578578
);
579579
}),
580580
);

0 commit comments

Comments
 (0)