diff --git a/sheet/lib/src/route/sheet_route.dart b/sheet/lib/src/route/sheet_route.dart index 5e4b8b8..d06e27b 100644 --- a/sheet/lib/src/route/sheet_route.dart +++ b/sheet/lib/src/route/sheet_route.dart @@ -373,11 +373,18 @@ class __SheetRouteContainerState extends State<_SheetRouteContainer> _routeController.addListener(onRouteAnimationUpdate); _sheetController.addListener(onSheetExtentUpdate); WidgetsBinding.instance.addPostFrameCallback((Duration timeStamp) { - _sheetController.relativeAnimateTo( + _sheetController + .relativeAnimateTo( route.initialExtent, duration: route.transitionDuration, curve: route.animationCurve ?? Curves.easeOut, - ); + ) + .then((_) { + if (_sheetController.hasClients) { + (_sheetController.position.context as SheetContext) + .initialAnimationFinished = true; + } + }); }); super.initState(); } diff --git a/sheet/lib/src/scroll_controller.dart b/sheet/lib/src/scroll_controller.dart index c2606c8..de72cd4 100644 --- a/sheet/lib/src/scroll_controller.dart +++ b/sheet/lib/src/scroll_controller.dart @@ -122,7 +122,12 @@ class SheetPrimaryScrollPosition extends ScrollPositionWithSingleContext { } if (sheetPosition.hasContentDimensions) { - sheetPosition.goBallistic(velocity); + if (sheetContext.initialAnimationFinished) { + sheetPosition.goBallistic(velocity); + } else { + goIdle(); + return; + } } if (velocity > 0.0 && diff --git a/sheet/lib/src/scrollable.dart b/sheet/lib/src/scrollable.dart index c90f2da..cfff31b 100644 --- a/sheet/lib/src/scrollable.dart +++ b/sheet/lib/src/scrollable.dart @@ -25,6 +25,8 @@ import 'package:sheet/src/widgets/min_interaction.dart'; abstract class SheetContext extends ScrollContext { double? get initialExtent; SheetPosition get position; + bool get initialAnimationFinished; + set initialAnimationFinished(bool initialAnimationFinished); } /// A widget that transform to user drag. @@ -326,6 +328,9 @@ class SheetState extends State @override AxisDirection get axisDirection => widget.axisDirection; + @override + bool initialAnimationFinished = false; + late SheetBehavior _configuration; ScrollPhysics? _physics; SheetController? _fallbackScrollController; @@ -775,7 +780,7 @@ class _ScrollSemantics extends SingleChildRenderObjectWidget { required this.allowImplicitScrolling, required this.semanticChildCount, super.child, - }) : assert(semanticChildCount == null || semanticChildCount >= 0); + }) : assert(semanticChildCount == null || semanticChildCount >= 0); final ScrollPosition position; final bool allowImplicitScrolling;