Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix update Sheet content while initializing #432

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions sheet/lib/src/route/sheet_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
7 changes: 6 additions & 1 deletion sheet/lib/src/scroll_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
7 changes: 6 additions & 1 deletion sheet/lib/src/scrollable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -326,6 +328,9 @@ class SheetState extends State<SheetScrollable>
@override
AxisDirection get axisDirection => widget.axisDirection;

@override
bool initialAnimationFinished = false;

late SheetBehavior _configuration;
ScrollPhysics? _physics;
SheetController? _fallbackScrollController;
Expand Down Expand Up @@ -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;
Expand Down