flutter_carousel_slider
flutter_carousel_slider copied to clipboard
Potentially unintended null-safe handling in nextPage
Future<void> nextPage(
{Duration? duration = const Duration(milliseconds: 300),
Curve? curve = Curves.linear}) async {
final bool isNeedResetTimer = _state!.options.pauseAutoPlayOnManualNavigate;
if (isNeedResetTimer) {
_state!.onResetTimer();
}
_setModeController();
await _state!.pageController!.nextPage(duration: duration!, curve: curve!);
if (isNeedResetTimer) {
_state!.onResumeTimer();
}
}
duration and curve are nullable but then you have duration! and curve! that indicate you don't expect them to be null. The same issue exists with previousPage.
You should do this instead:
Future<void> nextPage(
{Duration? duration,
Curve? curve}) async {
duration ??= const Duration(milliseconds: 300);
curve ??= Curves.linear;
final bool isNeedResetTimer = _state!.options.pauseAutoPlayOnManualNavigate;
if (isNeedResetTimer) {
_state!.onResetTimer();
}
_setModeController();
await _state!.pageController!.nextPage(duration: duration!, curve: curve!);
if (isNeedResetTimer) {
_state!.onResumeTimer();
}
}