Skip to content

Commit

Permalink
🔨 modified: non-nullable return type in ShowCaseWidget.Of(context) me…
Browse files Browse the repository at this point in the history
…thod.

✨ disableAnimation at ShowcaseWidget (SimformSolutionsPvtLtd#140)
  • Loading branch information
HappyMakadiyaS committed May 30, 2022
1 parent c680229 commit fa40663
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.1.6] - May 5, 2022 [Unreleased]

- Fixes [#140](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/140) - disableAnimation at ShowcaseWidget level

## [1.1.5] - March 4, 2022

- Fixed [#173](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/173) - showArrow not working
Expand Down
2 changes: 1 addition & 1 deletion example/lib/detailscreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class _DetailState extends State<Detail> {
super.initState();
WidgetsBinding.instance!.addPostFrameCallback(
(_) => Future.delayed(const Duration(milliseconds: 200), () {
ShowCaseWidget.of(myContext!)!.startShowCase([_one]);
ShowCaseWidget.of(myContext!).startShowCase([_one]);
}),
);
}
Expand Down
6 changes: 3 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _MailPageState extends State<MailPage> {
super.initState();
//Start showcase view after current widget frames are drawn.
WidgetsBinding.instance!.addPostFrameCallback(
(_) => ShowCaseWidget.of(context)!
(_) => ShowCaseWidget.of(context)
.startShowCase([_one, _two, _three, _four, _five, _six]),
);
mails = [
Expand Down Expand Up @@ -280,7 +280,7 @@ class _MailPageState extends State<MailPage> {
* currently rendered so the showcased keys are available in the
* render tree. */
scrollController.jumpTo(0);
ShowCaseWidget.of(context)!
ShowCaseWidget.of(context)
.startShowCase([_one, _two, _three, _four, _five, _six]);
});
},
Expand Down Expand Up @@ -317,7 +317,7 @@ class _MailPageState extends State<MailPage> {
),
).then((_) {
setState(() {
ShowCaseWidget.of(context)!.startShowCase([_four, _five]);
ShowCaseWidget.of(context).startShowCase([_four, _five]);
});
});
},
Expand Down
5 changes: 2 additions & 3 deletions lib/src/layout_overlays.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ class _OverlayBuilderState extends State<OverlayBuilder> {

void addToOverlay(OverlayEntry overlayEntry) async {
if (mounted) {
if (ShowCaseWidget.of(context)?.context != null &&
Overlay.of(ShowCaseWidget.of(context)!.context) != null) {
Overlay.of(ShowCaseWidget.of(context)!.context)!.insert(overlayEntry);
if (Overlay.of(ShowCaseWidget.of(context).context) != null) {
Overlay.of(ShowCaseWidget.of(context).context)!.insert(overlayEntry);
} else {
if (Overlay.of(context) != null) {
Overlay.of(context)!.insert(overlayEntry);
Expand Down
20 changes: 11 additions & 9 deletions lib/src/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ class _ShowcaseState extends State<Showcase> {

if (activeStep == widget.key) {
_scrollIntoView();
if (ShowCaseWidget.of(context)!.autoPlay) {
if (ShowCaseWidget.of(context).autoPlay) {
timer = Timer(
Duration(
seconds: ShowCaseWidget.of(context)!.autoPlayDelay.inSeconds),
seconds: ShowCaseWidget.of(context).autoPlayDelay.inSeconds),
_nextIfAny);
}
}
Expand All @@ -187,7 +187,7 @@ class _ShowcaseState extends State<Showcase> {
});
await Scrollable.ensureVisible(
widget.key.currentContext!,
duration: ShowCaseWidget.of(context)!.widget.scrollDuration,
duration: ShowCaseWidget.of(context).widget.scrollDuration,
alignment: 0.5,
);
setState(() {
Expand Down Expand Up @@ -216,19 +216,19 @@ class _ShowcaseState extends State<Showcase> {

void _nextIfAny() {
if (timer != null && timer!.isActive) {
if (ShowCaseWidget.of(context)!.autoPlayLockEnable) {
if (ShowCaseWidget.of(context).autoPlayLockEnable) {
return;
}
timer!.cancel();
} else if (timer != null && !timer!.isActive) {
timer = null;
}
ShowCaseWidget.of(context)!.completed(widget.key);
ShowCaseWidget.of(context).completed(widget.key);
}

void _getOnTargetTap() {
if (widget.disposeOnTap == true) {
ShowCaseWidget.of(context)!.dismiss();
ShowCaseWidget.of(context).dismiss();
widget.onTargetClick!();
} else {
(widget.onTargetClick ?? _nextIfAny).call();
Expand All @@ -237,7 +237,7 @@ class _ShowcaseState extends State<Showcase> {

void _getOnTooltipTap() {
if (widget.disposeOnTap == true) {
ShowCaseWidget.of(context)!.dismiss();
ShowCaseWidget.of(context).dismiss();
}
widget.onToolTipClick?.call();
}
Expand All @@ -250,7 +250,7 @@ class _ShowcaseState extends State<Showcase> {
) {
var blur = 0.0;
if (_showShowCase) {
blur = widget.blurValue ?? (ShowCaseWidget.of(context)?.blurValue) ?? 0;
blur = widget.blurValue ?? ShowCaseWidget.of(context).blurValue;
}

// Set blur to 0 if application is running on web and
Expand Down Expand Up @@ -319,7 +319,9 @@ class _ShowcaseState extends State<Showcase> {
contentWidth: widget.width,
onTooltipTap: _getOnTooltipTap,
contentPadding: widget.contentPadding,
disableAnimation: widget.disableAnimation,
disableAnimation:
ShowCaseWidget.of(context).disableAnimation ||
widget.disableAnimation,
animationDuration: widget.animationDuration,
),
],
Expand Down
8 changes: 6 additions & 2 deletions lib/src/showcase_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ShowCaseWidget extends StatefulWidget {
final bool autoPlay;
final Duration autoPlayDelay;
final bool autoPlayLockEnable;
final bool disableAnimation;
final Duration scrollDuration;

/// Default overlay blur used by showcase. if [Showcase.blurValue]
Expand All @@ -50,6 +51,7 @@ class ShowCaseWidget extends StatefulWidget {
this.autoPlayLockEnable = false,
this.blurValue = 0,
this.scrollDuration = const Duration(milliseconds: 300),
this.disableAnimation = false,
});

static GlobalKey? activeTargetWidget(BuildContext context) {
Expand All @@ -58,10 +60,10 @@ class ShowCaseWidget extends StatefulWidget {
?.activeWidgetIds;
}

static ShowCaseWidgetState? of(BuildContext context) {
static ShowCaseWidgetState of(BuildContext context) {
final state = context.findAncestorStateOfType<ShowCaseWidgetState>();
if (state != null) {
return context.findAncestorStateOfType<ShowCaseWidgetState>();
return state;
} else {
throw Exception('Please provide ShowCaseView context');
}
Expand All @@ -75,6 +77,7 @@ class ShowCaseWidgetState extends State<ShowCaseWidget> {
List<GlobalKey>? ids;
int? activeWidgetId;
late bool autoPlay;
late bool disableAnimation;
late Duration autoPlayDelay;
late bool autoPlayLockEnable;

Expand All @@ -86,6 +89,7 @@ class ShowCaseWidgetState extends State<ShowCaseWidget> {
super.initState();
autoPlayDelay = widget.autoPlayDelay;
autoPlay = widget.autoPlay;
disableAnimation = widget.disableAnimation;
autoPlayLockEnable = widget.autoPlayLockEnable;
}

Expand Down

0 comments on commit fa40663

Please sign in to comment.