Skip to content

Commit 789b7d8

Browse files
fix: 🐛 Improve showcase flow by consolidating finish logic and handling missing targets
1 parent 13ed611 commit 789b7d8

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## [Unreleased]
22

33
- Fixed [#650](https://github.com/SimformSolutionsPvtLtd/showcaseview/issues/650) - Fix null-check crash in ShowcaseService.getController during didUpdateWidget.
4+
- Fixed [#633](https://github.com/SimformSolutionsPvtLtd/showcaseview/issues/633) - Improve showcase flow by consolidating finish logic and handling missing targets
45

56
## [5.0.2]
67

lib/src/showcase/showcase_view.dart

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,7 @@ class ShowcaseView {
430430
_activeWidgetId = id;
431431

432432
if (_activeWidgetId! >= _ids!.length || _activeWidgetId!.isNegative) {
433-
_cleanupAfterSteps();
434-
onFinish?.call();
435-
for (final callback in _onFinishCallbacks) {
436-
callback.call();
437-
}
433+
_finishShowcase();
438434
} else {
439435
// Add a short delay before starting the next showcase to ensure proper state update
440436
// Then start the new showcase
@@ -505,6 +501,15 @@ class ShowcaseView {
505501
_changeSequence(type);
506502
return;
507503
}
504+
if (!skipIfTargetNotPresent &&
505+
controllerLength == 0 &&
506+
type == ShowcaseProgressType.forward) {
507+
// A forward step with no rendered target cannot be displayed.
508+
// Finishing here preserves expected UX and avoids progressing through
509+
// non-existent showcase indexes when next() is tapped.
510+
_finishShowcase();
511+
return;
512+
}
508513

509514
final firstController = controllers.firstOrNull;
510515
final isAutoScroll =
@@ -567,6 +572,18 @@ class ShowcaseView {
567572
if (autoPlay) _cancelTimer();
568573
}
569574

575+
/// Finishes the showcase and triggers all finish callbacks.
576+
///
577+
/// This centralizes completion behavior so all finish paths are consistent,
578+
/// including edge cases where a target is missing during forward progression.
579+
void _finishShowcase() {
580+
_cleanupAfterSteps();
581+
onFinish?.call();
582+
for (final callback in _onFinishCallbacks) {
583+
callback.call();
584+
}
585+
}
586+
570587
/// Cancels auto-play timer if active.
571588
void _cancelTimer() {
572589
if (!(_timer?.isActive ?? false)) return;

0 commit comments

Comments
 (0)