Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 5.1.1 [#unreleased]

- Fixed [#659](https://github.com/SimformSolutionsPvtLtd/showcaseview/issues/659) - Fix null-check crash in `ShowcaseController._initRootWidget` when the `Showcase` is unmounted in the same frame it mounts. Fixed by @[apurva-simform](https://github.com/apurva-simform)
- Fixed [#662](https://github.com/SimformSolutionsPvtLtd/showcaseview/issues/662) - Fix crash and stuck scroll-loading overlay when an auto-scroll target is unmounted while the scroll animation is running. Fixed by @[fellmonkey](https://github.com/fellmonkey)

## 5.1.0

Expand Down
31 changes: 31 additions & 0 deletions lib/src/showcase/showcase_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,43 @@ class ShowcaseController {
duration: showcaseView.scrollDuration,
alignment: config.scrollAlignment,
);
// The target may have been unmounted while we were waiting for the
// animation to finish (e.g. the page rebuilt after async data arrived).
if (!_mounted) {
isScrollRunning = false;
_recoverFromLostTarget();
return;
}
// For the cases when scrollAlignment causes overscroll.
await _waitForScrollToSettle();
if (!_mounted) {
isScrollRunning = false;
_recoverFromLostTarget();
return;
}

isScrollRunning = false;
setupShowcase(shouldUpdateOverlay: shouldUpdateOverlay);
}

/// Recovers the sequence when the target is unmounted mid auto-scroll.
///
/// The overlay is still showing [Showcase.scrollLoadingWidget] and cannot be
/// rebuilt from here without a context, so control is handed back to
/// [ShowcaseView]: skip ahead when [ShowcaseView.skipIfTargetNotPresent] is
/// set, otherwise end the showcase instead of leaving the barrier stuck.
void _recoverFromLostTarget() {
// [ShowcaseView._onStart] is still awaiting scrollIntoView, so defer until
// after the frame rather than re-entering the sequence mid-await.
_runLater(() {
if (showcaseView.skipIfTargetNotPresent) {
showcaseView.next(force: true);
} else {
showcaseView.dismiss();
}
});
}

/// Handles tap on barrier area.
///
/// Respects [Showcase.disableBarrierInteraction] and [ShowcaseView
Expand Down Expand Up @@ -468,6 +498,7 @@ class ShowcaseController {
Duration checkInterval = const Duration(milliseconds: 60),
int maxChecks = 120,
}) async {
if (!_mounted) return;
final scrollableState = Scrollable.maybeOf(_context);
if (scrollableState == null) return;

Expand Down
Loading