@@ -37,7 +37,9 @@ class FeaturesTourController {
3737
3838 /// The internal cached states that have been unregistered.
3939 final _cachedStates = SplayTreeMap <double , _FeaturesTourState >.from (
40- {}, (a, b) => a.compareTo (b));
40+ {},
41+ (a, b) => a.compareTo (b),
42+ );
4143
4244 final _globalKeys = < double , GlobalKey > {};
4345 final Map <double , Completer <_FeaturesTourState >> _pendingIndexes = {};
@@ -56,8 +58,10 @@ class FeaturesTourController {
5658 /// Registers the current FeaturesTour state.
5759 void _register (_FeaturesTourState state) {
5860 if (_debugLog && ! _cachedStates.containsKey (state.widget.index)) {
59- _logger? .log (() =>
60- 'Registering index ${state .widget .index }. Total states: ${_cachedStates .length + 1 }' );
61+ _logger? .log (
62+ () =>
63+ 'Registering index ${state .widget .index }. Total states: ${_cachedStates .length + 1 }' ,
64+ );
6165 }
6266 _states[state.widget.index] = state;
6367 _cachedStates[state.widget.index] = state;
@@ -74,8 +78,10 @@ class FeaturesTourController {
7478 /// Unregisters the current FeaturesTour state.
7579 void _unregister (_FeaturesTourState state) {
7680 if (_debugLog && _cachedStates.containsKey (state.widget.index)) {
77- _logger? .log (() =>
78- 'Unregistering index ${state .widget .index }. Total states: ${_cachedStates .length - 1 }' );
81+ _logger? .log (
82+ () =>
83+ 'Unregistering index ${state .widget .index }. Total states: ${_cachedStates .length - 1 }' ,
84+ );
7985 }
8086 _states.remove (state.widget.index);
8187 _cachedStates.remove (state.widget.index);
@@ -247,10 +253,10 @@ class FeaturesTourController {
247253 _logger? .log (() => 'This has been applied to all pages.' );
248254 await onState? .call (TourPreDialogHiddenByAppliedToAll (type));
249255 },
250- (value) {
256+ (value) async {
251257 _logger
252258 ? .log (() => 'The "Apply to all pages" checkbox is now $value .' );
253- onState? .call (TourPreDialogApplyToAllChanged (value));
259+ await onState? .call (TourPreDialogApplyToAllChanged (value));
254260 },
255261 );
256262
@@ -318,12 +324,16 @@ class FeaturesTourController {
318324
319325 bool shouldShowIntroduce;
320326 if (force != null ) {
321- _logger? .log (() =>
322- ' -> `force` is $force , so the introduction must respect it.' );
327+ _logger? .log (
328+ () =>
329+ ' -> `force` is $force , so the introduction must respect it.' ,
330+ );
323331 shouldShowIntroduce = force;
324332 } else {
325- _logger? .log (() =>
326- ' -> `force` is null, so the introduction will act like normal.' );
333+ _logger? .log (
334+ () =>
335+ ' -> `force` is null, so the introduction will act like normal.' ,
336+ );
327337 final isShown = _prefs! .getBool (key);
328338 shouldShowIntroduce = isShown != true ;
329339 }
@@ -333,8 +343,10 @@ class FeaturesTourController {
333343 }
334344
335345 if (! shouldShowIntroduce) {
336- _logger? .log (() =>
337- ' -> This widget has been introduced. Moving to the next widget.' );
346+ _logger? .log (
347+ () =>
348+ ' -> This widget has been introduced. Moving to the next widget.' ,
349+ );
338350 await _removeState (state, false );
339351 await onState
340352 ? .call (TourSkippedIntroduction (index: state.widget.index));
@@ -431,21 +443,26 @@ class FeaturesTourController {
431443
432444 // Waits for the next state to appear if `nextIndex` is non-null.
433445 if (nextIndex != null ) {
434- _logger? .log (() =>
435- 'The `nextIndex` is non-null. Waiting for the next index: $nextIndex ...' );
446+ _logger? .log (
447+ () =>
448+ 'The `nextIndex` is non-null. Waiting for the next index: $nextIndex ...' ,
449+ );
436450
437451 nextState = await _nextIndex (nextIndex, nextIndexTimeout);
438452
439453 if (nextState == null ) {
440- _logger? .log (() =>
441- 'Cannot wait for the next index $nextIndex because the timeout was reached. Using the next ordered value instead.' );
454+ _logger? .log (
455+ () =>
456+ 'Cannot wait for the next index $nextIndex because the timeout was reached. Using the next ordered value instead.' ,
457+ );
442458
443459 // Adds the timeout state index to the introduced list so it will not
444460 // be introduced even when it's shown.
445461 _introducedIndexes.add (nextIndex);
446462 } else {
447463 _logger? .log (
448- () => 'The next index is available with state: $nextState .' );
464+ () => 'The next index is available with state: $nextState .' ,
465+ );
449466 }
450467 } else {
451468 nextState = null ;
@@ -534,65 +551,67 @@ class FeaturesTourController {
534551 ),
535552 );
536553
537- final overlayEntry = OverlayEntry (builder: (ctx) {
538- return GestureDetector (
539- onTap: childConfig.barrierDismissible
540- ? () => complete (IntroduceResult .next)
541- : null ,
542- child: Material (
543- color: Colors .transparent,
544- child: FeaturesChild (
545- globalKey: _globalKeys[state.widget.index]! ,
546- childConfig: childConfig,
547- introduce: state.widget.introduce,
548- introduceConfig: introduceConfig,
549- skip: SafeArea (
550- child: Padding (
551- padding: const EdgeInsets .all (12 ),
552- child: skipButton,
554+ final overlayEntry = OverlayEntry (
555+ builder: (ctx) {
556+ return GestureDetector (
557+ onTap: childConfig.barrierDismissible
558+ ? () => complete (IntroduceResult .next)
559+ : null ,
560+ child: Material (
561+ color: Colors .transparent,
562+ child: FeaturesChild (
563+ globalKey: _globalKeys[state.widget.index]! ,
564+ childConfig: childConfig,
565+ introduce: state.widget.introduce,
566+ introduceConfig: introduceConfig,
567+ skip: SafeArea (
568+ child: Padding (
569+ padding: const EdgeInsets .all (12 ),
570+ child: skipButton,
571+ ),
553572 ),
554- ) ,
555- skipConfig : skipConfig,
556- next : SafeArea (
557- child : Padding (
558- padding : const EdgeInsets . all ( 12 ) ,
559- child : nextButton ,
573+ skipConfig : skipConfig ,
574+ next : SafeArea (
575+ child : Padding (
576+ padding : const EdgeInsets . all ( 12 ),
577+ child : nextButton ,
578+ ) ,
560579 ),
561- ) ,
562- doneConfig : doneConfig,
563- done : SafeArea (
564- child : Padding (
565- padding : const EdgeInsets . all ( 12 ) ,
566- child : doneButton ,
580+ doneConfig : doneConfig ,
581+ done : SafeArea (
582+ child : Padding (
583+ padding : const EdgeInsets . all ( 12 ),
584+ child : doneButton ,
585+ ) ,
567586 ),
568- ) ,
569- isLastState : isLastState ,
570- nextConfig : nextConfig ,
571- padding : introduceConfig.padding ,
572- alignment : introduceConfig.alignment ,
573- quadrantAlignment : introduceConfig.quadrantAlignment,
574- child : GestureDetector (
575- onTap : () {
576- complete ( IntroduceResult .next);
577- },
578- child : Material (
579- color : Colors .transparent,
580- child: AbsorbPointer (
581- child : UnfeaturesTour (
582- // TODO(lamnhan066): Remove deprecated `child` in the next stable release.
583- // ignore: deprecated_member_use_from_same_package
584- child : childConfig.child ? . call (state.widget.child) ??
585- childConfig.builder
586- ? . call (context, state.widget.child) ??
587- state.widget.child ,
587+ isLastState : isLastState ,
588+ nextConfig : nextConfig ,
589+ padding : introduceConfig.padding ,
590+ alignment : introduceConfig.alignment ,
591+ quadrantAlignment : introduceConfig.quadrantAlignment ,
592+ child : GestureDetector (
593+ onTap : () {
594+ complete ( IntroduceResult .next);
595+ },
596+ child : Material (
597+ color : Colors .transparent,
598+ child : AbsorbPointer (
599+ child: UnfeaturesTour (
600+ // TODO(lamnhan066): Remove deprecated `child` in the next stable release.
601+ // ignore: deprecated_member_use_from_same_package
602+ child : childConfig.child ? . call (state.widget.child) ??
603+ childConfig.builder
604+ ? . call (context, state.widget.child) ??
605+ state.widget.child,
606+ ) ,
588607 ),
589608 ),
590609 ),
591610 ),
592611 ),
593- ),
594- );
595- } );
612+ );
613+ },
614+ );
596615
597616 if (! context.mounted) return IntroduceResult .notMounted;
598617
@@ -647,9 +666,7 @@ class FeaturesTourController {
647666 }
648667 }
649668
650- for (final key in removedIndexes) {
651- _states.remove (key);
652- }
669+ removedIndexes.forEach (_states.remove);
653670 }
654671
655672 /// Shows the pre-dialog if possible.
0 commit comments