From 0b5468f2c5655ebf2a685c62919d149420d142a1 Mon Sep 17 00:00:00 2001 From: bcaspe Date: Sun, 17 Nov 2024 08:48:39 +0100 Subject: [PATCH 01/14] Update stepper.dart Added a call to widget.onChanged when stepper is started --- lib/src/stepper.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/stepper.dart b/lib/src/stepper.dart index 00982f0..0511ed7 100644 --- a/lib/src/stepper.dart +++ b/lib/src/stepper.dart @@ -200,6 +200,8 @@ class OnboardingStepperState extends State await Future.delayed(step.delay); } + widget.onChanged?.call(stepperIndex); + setTweensAndAnimate(step); step.focusNode.requestFocus(); } From 1f2b6aec0f24defb02d36fc8ea4909625e0a18bc Mon Sep 17 00:00:00 2001 From: bcaspe Date: Sun, 17 Nov 2024 09:28:18 +0100 Subject: [PATCH 02/14] Update stepper.dart --- lib/src/stepper.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/stepper.dart b/lib/src/stepper.dart index 0511ed7..b650263 100644 --- a/lib/src/stepper.dart +++ b/lib/src/stepper.dart @@ -200,7 +200,7 @@ class OnboardingStepperState extends State await Future.delayed(step.delay); } - widget.onChanged?.call(stepperIndex); + widget.onChanged?.call(stepperIndex - 1); setTweensAndAnimate(step); step.focusNode.requestFocus(); From e9b096574de459e563afbec48e1eb0206cf17bbb Mon Sep 17 00:00:00 2001 From: bcaspe Date: Sun, 17 Nov 2024 09:43:07 +0100 Subject: [PATCH 03/14] Update stepper.dart --- lib/src/stepper.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/stepper.dart b/lib/src/stepper.dart index b650263..be53e1f 100644 --- a/lib/src/stepper.dart +++ b/lib/src/stepper.dart @@ -33,6 +33,7 @@ class OnboardingStepper extends StatefulWidget { this.pulseDuration = const Duration(milliseconds: 1000), this.onChanged, this.onEnd, + this.onStart, this.autoSizeTexts = false, this.stepIndexes = const [], this.debugBoundaries = false, @@ -60,6 +61,8 @@ class OnboardingStepper extends StatefulWidget { /// By default stepIndexes os an empty array final List stepIndexes; + final VoidCallback onStart; + /// `onChanged` is called every time when the previous step has faded out, /// /// before the next step is shown with a value of the step index on which the user was @@ -200,7 +203,9 @@ class OnboardingStepperState extends State await Future.delayed(step.delay); } - widget.onChanged?.call(stepperIndex - 1); + if (widget.onStart != null) { + widget.onStart!(); + } setTweensAndAnimate(step); step.focusNode.requestFocus(); From d009bc134780fe38ffaa5712c48f715bbd51b600 Mon Sep 17 00:00:00 2001 From: bcaspe Date: Sun, 17 Nov 2024 09:44:16 +0100 Subject: [PATCH 04/14] Update onboarding_widget.dart --- lib/src/onboarding_widget.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/src/onboarding_widget.dart b/lib/src/onboarding_widget.dart index 1fe5411..d5b0021 100644 --- a/lib/src/onboarding_widget.dart +++ b/lib/src/onboarding_widget.dart @@ -16,6 +16,7 @@ class Onboarding extends StatefulWidget { this.initialIndex = 0, this.onChanged, this.onEnd, + this.onStart, this.autoSizeTexts = false, required this.steps, required this.child, @@ -35,6 +36,8 @@ class Onboarding extends StatefulWidget { /// A callback that signal when the `Onboarding` is finished or stopped final ValueChanged? onEnd; + final VoidCallback? onStart; + /// By default, the value used is false /// Sometimes the `titleText` and the `bodyText` might not fit well in the constrained label box, /// because of the long texts, longer translations or smaller screens. @@ -178,6 +181,7 @@ class OnboardingState extends State { debugBoundaries: widget.debugBoundaries, scaleWidth: widget.scaleWidth, scaleHeight: widget.scaleHeight, + onStart: onStart, onChanged: (int index) { controller.setCurrentIndex(index); widget.onChanged?.call(index); From 3de91f6b44a8c0a5361f811a43c6615f2fd8c3cc Mon Sep 17 00:00:00 2001 From: bcaspe Date: Sun, 17 Nov 2024 13:10:39 +0100 Subject: [PATCH 05/14] Update step.dart --- lib/src/step.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/src/step.dart b/lib/src/step.dart index 0c592d0..b5092e5 100644 --- a/lib/src/step.dart +++ b/lib/src/step.dart @@ -96,6 +96,7 @@ class OnboardingStep { this.showPulseAnimation = false, this.pulseInnerColor = defaultInnerPulseColor, this.pulseOuterColor = defaultOuterPulseColor, + this.onShowStep, this.onTapCallback, }) : assert(() { if (titleTextColor == null && titleTextStyle == null) { @@ -135,6 +136,8 @@ class OnboardingStep { /// is required final FocusNode focusNode; + final VoidCallback? onShowStep; + /// By default, the value used is `TextAlign.start` final TextAlign textAlign; @@ -292,6 +295,7 @@ class OnboardingStep { Color? pulseInnerColor, Color? pulseOuterColor, TapCallback? onTapCallback, + VoidCallback? onShowStep, }) { return OnboardingStep( key: key ?? this.key, @@ -320,6 +324,7 @@ class OnboardingStep { pulseInnerColor: pulseInnerColor ?? this.pulseInnerColor, pulseOuterColor: pulseOuterColor ?? this.pulseOuterColor, onTapCallback: onTapCallback ?? this.onTapCallback, + onShowStep: onShowStep ?? this.onShowStep, ); } @@ -352,6 +357,7 @@ class OnboardingStep { pulseInnerColor: $pulseInnerColor, pulseOuterColor: $pulseOuterColor, onTapCallback: $onTapCallback, + onShowStep: $onShowStep, )'''; } @@ -385,6 +391,7 @@ class OnboardingStep { other.showPulseAnimation == showPulseAnimation && other.pulseInnerColor == pulseInnerColor && other.pulseOuterColor == pulseOuterColor && + other.onShowStep == onShowStep && other.onTapCallback == onTapCallback; } @@ -415,6 +422,7 @@ class OnboardingStep { showPulseAnimation.hashCode ^ pulseInnerColor.hashCode ^ pulseOuterColor.hashCode ^ + onShowStep.hashCode ^ onTapCallback.hashCode; } } From 2feb060595923f5bfc9714cb3b82f96a333a21e0 Mon Sep 17 00:00:00 2001 From: bcaspe Date: Sun, 17 Nov 2024 13:12:07 +0100 Subject: [PATCH 06/14] Update stepper.dart --- lib/src/stepper.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/src/stepper.dart b/lib/src/stepper.dart index be53e1f..0b377ea 100644 --- a/lib/src/stepper.dart +++ b/lib/src/stepper.dart @@ -207,6 +207,10 @@ class OnboardingStepperState extends State widget.onStart!(); } + if (step.onShowStep != null) { + step.onShowStep!(); + } + setTweensAndAnimate(step); step.focusNode.requestFocus(); } @@ -265,6 +269,11 @@ class OnboardingStepperState extends State final OnboardingStep step = widget.steps[stepperIndex]; await Future.delayed(step.delay); + if (step.onShowStep != null) { + step.onShowStep!(); + } + + if (widget.stepIndexes.indexWhere((int el) => el == stepperIndex) != -1) { setTweensAndAnimate(step); step.focusNode.requestFocus(); From 701d14a0fbca182d5308c6fef530457ce115a0fc Mon Sep 17 00:00:00 2001 From: bcaspe Date: Sun, 17 Nov 2024 13:21:24 +0100 Subject: [PATCH 07/14] Update onboarding_widget.dart --- lib/src/onboarding_widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/onboarding_widget.dart b/lib/src/onboarding_widget.dart index d5b0021..f17eb2a 100644 --- a/lib/src/onboarding_widget.dart +++ b/lib/src/onboarding_widget.dart @@ -181,7 +181,7 @@ class OnboardingState extends State { debugBoundaries: widget.debugBoundaries, scaleWidth: widget.scaleWidth, scaleHeight: widget.scaleHeight, - onStart: onStart, + onStart: widget.onStart, onChanged: (int index) { controller.setCurrentIndex(index); widget.onChanged?.call(index); From 24e33060064a79cdacd8161352adf1bcf8cf25ac Mon Sep 17 00:00:00 2001 From: bcaspe Date: Sun, 17 Nov 2024 13:30:34 +0100 Subject: [PATCH 08/14] Update stepper.dart --- lib/src/stepper.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/stepper.dart b/lib/src/stepper.dart index 0b377ea..93ca36c 100644 --- a/lib/src/stepper.dart +++ b/lib/src/stepper.dart @@ -61,7 +61,7 @@ class OnboardingStepper extends StatefulWidget { /// By default stepIndexes os an empty array final List stepIndexes; - final VoidCallback onStart; + final VoidCallback? onStart; /// `onChanged` is called every time when the previous step has faded out, /// From a757b61a269eddc16d9d4af8d506cb2f8e760915 Mon Sep 17 00:00:00 2001 From: bcaspe Date: Sun, 17 Nov 2024 22:03:24 +0100 Subject: [PATCH 09/14] Update stepper.dart --- lib/src/stepper.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/stepper.dart b/lib/src/stepper.dart index 93ca36c..21be8ba 100644 --- a/lib/src/stepper.dart +++ b/lib/src/stepper.dart @@ -245,6 +245,9 @@ class OnboardingStepperState extends State if (stepperIndex > 0) { await Future.delayed(step.delay); } + if (step.onShowStep != null) { + step.onShowStep!(); + } if (stepperIndex < widget.steps.length && stepperIndex >= 0) { setTweensAndAnimate(step); step.focusNode.requestFocus(); @@ -270,8 +273,8 @@ class OnboardingStepperState extends State await Future.delayed(step.delay); if (step.onShowStep != null) { - step.onShowStep!(); - } + step.onShowStep!(); + } if (widget.stepIndexes.indexWhere((int el) => el == stepperIndex) != -1) { From fc77c997ff5d08839b26f8ee9914e2abc80faa39 Mon Sep 17 00:00:00 2001 From: bcaspe Date: Mon, 18 Nov 2024 15:06:02 +0100 Subject: [PATCH 10/14] Update step.dart --- lib/src/step.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/step.dart b/lib/src/step.dart index b5092e5..11e27e6 100644 --- a/lib/src/step.dart +++ b/lib/src/step.dart @@ -136,7 +136,7 @@ class OnboardingStep { /// is required final FocusNode focusNode; - final VoidCallback? onShowStep; + final void Function(VoidCallback nextStep)? onShowStep; /// By default, the value used is `TextAlign.start` final TextAlign textAlign; From 61ebab6ad2a3681bbf4336c11667b8b7fd3ca2b4 Mon Sep 17 00:00:00 2001 From: bcaspe Date: Mon, 18 Nov 2024 15:49:53 +0100 Subject: [PATCH 11/14] Update stepper.dart passing next step to the onShowStep so that it can call next step on it's own --- lib/src/stepper.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/stepper.dart b/lib/src/stepper.dart index 21be8ba..723f624 100644 --- a/lib/src/stepper.dart +++ b/lib/src/stepper.dart @@ -208,7 +208,7 @@ class OnboardingStepperState extends State } if (step.onShowStep != null) { - step.onShowStep!(); + step.onShowStep!(_nextStep); } setTweensAndAnimate(step); @@ -246,7 +246,7 @@ class OnboardingStepperState extends State await Future.delayed(step.delay); } if (step.onShowStep != null) { - step.onShowStep!(); + step.onShowStep!(_nextStep); } if (stepperIndex < widget.steps.length && stepperIndex >= 0) { setTweensAndAnimate(step); @@ -273,7 +273,7 @@ class OnboardingStepperState extends State await Future.delayed(step.delay); if (step.onShowStep != null) { - step.onShowStep!(); + step.onShowStep!(_nextStep); } From 5200c107ee1993ab7bb881df7b265cf7c83edfc3 Mon Sep 17 00:00:00 2001 From: bcaspe Date: Tue, 19 Nov 2024 09:04:40 +0100 Subject: [PATCH 12/14] Update step.dart --- lib/src/step.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/step.dart b/lib/src/step.dart index 11e27e6..507ed42 100644 --- a/lib/src/step.dart +++ b/lib/src/step.dart @@ -295,7 +295,7 @@ class OnboardingStep { Color? pulseInnerColor, Color? pulseOuterColor, TapCallback? onTapCallback, - VoidCallback? onShowStep, + Function(VoidCallback nextStep)? onShowStep, }) { return OnboardingStep( key: key ?? this.key, From 7ac3c471a18c963477ed691fb279436a5ef58d5b Mon Sep 17 00:00:00 2001 From: bcaspe Date: Tue, 19 Nov 2024 15:40:14 +0100 Subject: [PATCH 13/14] Update step.dart added new typedef ShowStepCallback updated indentation --- lib/src/step.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/src/step.dart b/lib/src/step.dart index 507ed42..ad80ac6 100644 --- a/lib/src/step.dart +++ b/lib/src/step.dart @@ -46,6 +46,9 @@ typedef StepPainterBuilder = CustomPainter Function( typedef TapCallback = void Function( TapArea area, VoidCallback next, VoidCallback close); +typedef ShowStepCallback = void Function( + VoidCallback next); + @immutable class OnboardingStep { /// At least a [titleText] or a [bodyText] should be provided. @@ -136,8 +139,6 @@ class OnboardingStep { /// is required final FocusNode focusNode; - final void Function(VoidCallback nextStep)? onShowStep; - /// By default, the value used is `TextAlign.start` final TextAlign textAlign; @@ -268,6 +269,8 @@ class OnboardingStep { final TapCallback? onTapCallback; + final ShowStepCallback? onShowStep; + OnboardingStep copyWith({ Key? key, FocusNode? focusNode, @@ -295,7 +298,7 @@ class OnboardingStep { Color? pulseInnerColor, Color? pulseOuterColor, TapCallback? onTapCallback, - Function(VoidCallback nextStep)? onShowStep, + ShowStepCallback? onShowStep, }) { return OnboardingStep( key: key ?? this.key, @@ -422,7 +425,7 @@ class OnboardingStep { showPulseAnimation.hashCode ^ pulseInnerColor.hashCode ^ pulseOuterColor.hashCode ^ - onShowStep.hashCode ^ + onShowStep.hashCode ^ onTapCallback.hashCode; } } From 2fc246586d08ef200225599ea901ad16f37dd6cd Mon Sep 17 00:00:00 2001 From: bcaspe Date: Wed, 5 Feb 2025 11:35:07 +0100 Subject: [PATCH 14/14] Update stepper.dart --- lib/src/stepper.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/stepper.dart b/lib/src/stepper.dart index 723f624..be06ccb 100644 --- a/lib/src/stepper.dart +++ b/lib/src/stepper.dart @@ -282,6 +282,7 @@ class OnboardingStepperState extends State step.focusNode.requestFocus(); } } + if (!mounted) return; setState(() { calcWidgetRect(widget.steps[stepperIndex]); });