Skip to content

Commit 1df746b

Browse files
fix: 🩹 Added missing assertions for Showcase.withWidget() (#515) (#517)
1 parent 46c0dfc commit 1df746b

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
Added controller to manage showcase
1919
- CHORE [#514](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/514) -
2020
Bumped dart minimum sdk to 2.19.6
21+
- Fixed [#515](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/515) - Added
22+
missing assertions for `Showcase.withWidget()`.
2123

2224
## [4.0.1]
2325
- Fixed [#493](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/493) - ShowCase.withWidget not showing issue

lib/src/showcase/showcase.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,15 @@ class Showcase extends StatefulWidget {
426426
),
427427
assert(
428428
onTargetClick == null || disposeOnTap != null,
429-
"disposeOnTap is required if you're using onTargetClick",
429+
"`disposeOnTap` is required if you're using `onTargetClick`",
430430
),
431431
assert(
432432
disposeOnTap == null || onTargetClick != null,
433-
"onTargetClick is required if you're using disposeOnTap",
433+
"`onTargetClick` is required if you're using `disposeOnTap`",
434434
),
435435
assert(
436436
onBarrierClick == null || disableBarrierInteraction == false,
437-
"can't use onBarrierClick & disableBarrierInteraction property at same time",
437+
"can't use `onBarrierClick` & `disableBarrierInteraction` property at same time",
438438
);
439439

440440
/// Creates a Showcase widget with a custom tooltip widget.
@@ -546,9 +546,17 @@ class Showcase extends StatefulWidget {
546546
overlayOpacity >= 0.0 && overlayOpacity <= 1.0,
547547
'overlay opacity must be between 0 and 1.',
548548
),
549+
assert(
550+
onTargetClick == null || disposeOnTap != null,
551+
"`disposeOnTap` is required if you're using `onTargetClick`",
552+
),
553+
assert(
554+
disposeOnTap == null || onTargetClick != null,
555+
"`onTargetClick` is required if you're using `disposeOnTap`",
556+
),
549557
assert(
550558
onBarrierClick == null || disableBarrierInteraction == false,
551-
"can't use onBarrierClick & disableBarrierInteraction property at same time",
559+
"can't use `onBarrierClick` & `disableBarrierInteraction` property at same time",
552560
);
553561

554562
@override

lib/src/showcase_widget.dart

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,6 @@ class ShowCaseWidgetState extends State<ShowCaseWidget> {
486486
required ShowcaseController controller,
487487
required int showcaseId,
488488
}) {
489-
assert(
490-
StackTrace.current.toString().contains('_ShowcaseState'),
491-
'This method should only be called from `Showcase` class',
492-
);
493489
_showcaseControllers
494490
.putIfAbsent(
495491
key,
@@ -505,22 +501,13 @@ class ShowCaseWidgetState extends State<ShowCaseWidget> {
505501
void removeShowcaseController({
506502
required GlobalKey key,
507503
required int uniqueShowcaseKey,
508-
}) {
509-
assert(
510-
StackTrace.current.toString().contains('_ShowcaseState'),
511-
'This method should only be called from `Showcase` class',
512-
);
513-
_showcaseControllers[key]?.remove(uniqueShowcaseKey);
514-
}
504+
}) =>
505+
_showcaseControllers[key]?.remove(uniqueShowcaseKey);
515506

516507
ShowcaseController getControllerForShowcase({
517508
required GlobalKey key,
518509
required int showcaseId,
519510
}) {
520-
assert(
521-
StackTrace.current.toString().contains('_ShowcaseState'),
522-
'This method should only be called from `Showcase` class',
523-
);
524511
assert(
525512
_showcaseControllers[key]?[showcaseId] != null,
526513
'Please register showcase controller first by calling '

0 commit comments

Comments
 (0)