Skip to content

Commit 07b5ce2

Browse files
committed
chore: align code with very good analysis v10
1 parent 4af9b60 commit 07b5ce2

10 files changed

Lines changed: 744 additions & 624 deletions

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ packages:
6363
path: ".."
6464
relative: true
6565
source: path
66-
version: "0.5.0-rc.7"
66+
version: "0.5.0-rc.10"
6767
ffi:
6868
dependency: transitive
6969
description:

lib/src/components/cover_dialog.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ void showCover(
1010
) {
1111
if (!context.mounted) {
1212
printDebug?.call(
13-
'Cannot show the cover because the build context is not mounted');
13+
'Cannot show the cover because the build context is not mounted',
14+
);
1415
return;
1516
}
1617

@@ -21,12 +22,14 @@ void showCover(
2122

2223
printDebug?.call('Showing the cover');
2324

24-
_coverOverlay = OverlayEntry(builder: (ctx) {
25-
return Material(
26-
color: color,
27-
child: const SizedBox.shrink(),
28-
);
29-
});
25+
_coverOverlay = OverlayEntry(
26+
builder: (ctx) {
27+
return Material(
28+
color: color,
29+
child: const SizedBox.shrink(),
30+
);
31+
},
32+
);
3033

3134
Overlay.of(context, rootOverlay: true).insert(_coverOverlay!);
3235
}

lib/src/components/dialogs.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ Future<PreDialogButtonType> showPreDialog(
4040
OverlayEntry? overlayEntry;
4141

4242
if (config.customDialogBuilder != null) {
43-
completer.complete(config.customDialogBuilder!(
44-
context,
45-
(value) async {
46-
isChecked = value;
47-
onApplyToAllPagesCheckboxChanged?.call(value);
48-
},
49-
));
43+
completer.complete(
44+
config.customDialogBuilder!(
45+
context,
46+
(value) async {
47+
isChecked = value;
48+
onApplyToAllPagesCheckboxChanged?.call(value);
49+
},
50+
),
51+
);
5052
await onPreDialogIsDisplayed(true);
5153
} else {
5254
overlayEntry = OverlayEntry(
@@ -76,7 +78,8 @@ Future<PreDialogButtonType> showPreDialog(
7678
),
7779
backgroundColor: config.backgroundColor,
7880
shape: RoundedRectangleBorder(
79-
borderRadius: BorderRadius.circular(config.borderRadius)),
81+
borderRadius: BorderRadius.circular(config.borderRadius),
82+
),
8083
actions: [
8184
TextButton(
8285
onPressed: () async {

lib/src/components/features_child.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,15 @@ class _FeaturesChildState extends State<FeaturesChild>
244244
_scaleAnimation = Tween<double>(
245245
begin: widget.childConfig.zoomScale,
246246
end: 1,
247-
).animate(CurvedAnimation(
248-
parent: _scaleController,
249-
curve: widget.childConfig.curve,
250-
));
247+
).animate(
248+
CurvedAnimation(
249+
parent: _scaleController,
250+
curve: widget.childConfig.curve,
251+
),
252+
);
251253

252254
if (widget.childConfig.enableAnimation) {
253-
_scaleController.repeat(reverse: true);
255+
_scaleController.repeat(reverse: true).ignore();
254256
} else {
255257
_scaleController.value = 1;
256258
_scaleController.stop();

lib/src/features_tour.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class FeaturesTour extends StatefulWidget {
5757
/// If `canPop` is `true`, the tour will be dismissed when popped. Otherwise,
5858
/// it blocks the current route from being popped.
5959
@Deprecated(
60-
'Use `FeaturesTourController.start(popToSkip: true)` instead. This parameter has no effect for now.')
60+
'Use `FeaturesTourController.start(popToSkip: true)` instead. This parameter has no effect for now.',
61+
)
6162
bool canPop = true,
6263
@Deprecated(
6364
'Use `nextIndex` instead. This will be removed in the next major version.',
@@ -201,8 +202,6 @@ class FeaturesTour extends StatefulWidget {
201202

202203
/// Sets a global logger for all controllers.
203204
@visibleForTesting
204-
// For testing purposes only.
205-
// ignore: use_setters_to_change_properties
206205
static void setTestingLogger(Logger? logger) {
207206
if (logger == null) {
208207
_debugLog = false;

lib/src/features_tour_controller.dart

Lines changed: 89 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -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.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ dependencies:
2525
dev_dependencies:
2626
flutter_test:
2727
sdk: flutter
28-
very_good_analysis: ^9.0.0
28+
very_good_analysis: ^10.0.0

0 commit comments

Comments
 (0)