Skip to content
Next Next commit
Allows for the animation duration to be adjusted using SlotLayout.from()
  • Loading branch information
oravecz-jpmc committed Apr 12, 2024
commit c8ab2d41ab4f92e711c389a5aeacd508146ba0e7
8 changes: 7 additions & 1 deletion packages/flutter_adaptive_scaffold/lib/src/slot_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ class SlotLayout extends StatefulWidget {
WidgetBuilder? builder,
Widget Function(Widget, Animation<double>)? inAnimation,
Widget Function(Widget, Animation<double>)? outAnimation,
Duration? duration,
required Key key,
}) =>
SlotLayoutConfig._(
builder: builder,
inAnimation: inAnimation,
outAnimation: outAnimation,
duration: duration,
key: key,
);

Expand All @@ -96,7 +98,7 @@ class _SlotLayoutState extends State<SlotLayout>
chosenWidget = SlotLayout.pickWidget(context, widget.config);
bool hasAnimation = false;
return AnimatedSwitcher(
duration: const Duration(milliseconds: 1000),
duration: chosenWidget?.duration ?? const Duration(milliseconds: 1000),
layoutBuilder: (Widget? currentChild, List<Widget> previousChildren) {
final Stack elements = Stack(
children: <Widget>[
Expand Down Expand Up @@ -137,6 +139,7 @@ class SlotLayoutConfig extends StatelessWidget {
required this.builder,
this.inAnimation,
this.outAnimation,
this.duration,
});

/// The child Widget that [SlotLayout] eventually returns with an animation.
Expand All @@ -160,6 +163,9 @@ class SlotLayoutConfig extends StatelessWidget {
/// as the returned widget.
final Widget Function(Widget, Animation<double>)? outAnimation;

/// The amount of time taken by the execution of the in and out animations
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is missing the period at the end.

final Duration? duration;

/// An empty [SlotLayoutConfig] to be placed in a slot to indicate that the slot
/// should show nothing.
static SlotLayoutConfig empty() {
Expand Down