flutter_carousel_slider
flutter_carousel_slider copied to clipboard
Null check operator used on a null value
This is from an automated error report from one of our users. I don't know what actions led to this exception.
monodrag.dart in DragGestureRecognizer.acceptGesture at line 324
carousel_slider.dart in _MultipleGestureRecognizer.rejectGesture at line 336
arena.dart in GestureArenaManager.sweep at line 160
I hope this is enough information to figure out what causes it.
I am also facing the same issue.
The following _CastError was thrown building AnimatedBuilder(animation: PageController#a54d1(one client, offset 3600000.0), dirty, state: _AnimatedState#c1ea5): Null check operator used on a null value
The relevant error-causing widget was:
CarouselSlider file:///D:/external%20projects/MVSCCs/MVSCCS_APP/lib/src/widgets/HomeSliderWidget.dart:38:15
When the exception was thrown, this was the stack:
#0 _CarouselSliderState.build.
I'm also facing the same issue... The following _CastError was thrown building AnimatedBuilder(animation: PageController#c7a83(one client, offset 1803636.4), dirty, state: _AnimatedState#cfddc): Null check operator used on a null value
My error was gone by using the updated package carousel_slider: ^2.3.1. May be by updating the package will solve your problem.
I am using the latest version, and still see this error. It does not happen often, but it still happens.
I am also facing this issue. Please provide a solution
same here, I am also facing this issue
so am I. haha
Run the following commands in terminal flutter channel stable flutter upgrade
I am up to date
Flutter is already up to date on channel stable
Flutter 2.0.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b1395592de (12 days ago) • 2021-04-01 14:25:01 -0700
Engine • revision 2dce47073a
Tools • Dart 2.12.2
my code
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:carousel_slider/carousel_controller.dart';
import 'package:carousel_slider/carousel_slider.dart';
.
.
.
@override
Widget build(BuildContext context) {
final ValueNotifier<int> activeIndex = useState(0);
final CarouselController _controller = CarouselController();
return Column(
children: [
CarouselSlider.builder(
itemCount: groupedStyles.length,
options: CarouselOptions(
height: 400,
// viewportFraction: 1.0,
enableInfiniteScroll: false,
onPageChanged: (int index, _) => activeIndex.value = index),
itemBuilder: (_, int index, int realIndex) {
return Container(height: 100, width: 100, color: Colors.red);
}),
AnimatedSmoothIndicator(
activeIndex: activeIndex.value,
count: groupedStyles.length,
effect: const WormEffect(),
onDotClicked: (int index) async {
debugPrint(index.toString());
await _controller.animateToPage(index);
})
],
);
}
The problem seems to be here: (_state is null, but forced to be not)
flutter_carousel_slider code
class CarouselControllerImpl implements CarouselController {
CarouselState? _state;
.
.
.
Future<void> animateToPage(int page,
{Duration? duration = const Duration(milliseconds: 300),
Curve? curve = Curves.linear}) async {
final bool isNeedResetTimer = _state!.options.pauseAutoPlayOnManualNavigate; // <-- state is null
if (isNeedResetTimer) {
_state!.onResetTimer();
}
final index = getRealIndex(_state!.pageController!.page!.toInt(),
_state!.realPage - _state!.initialPage, _state!.itemCount);
_setModeController();
await _state!.pageController!.animateToPage(
_state!.pageController!.page!.toInt() + page - index,
duration: duration!,
curve: curve!);
if (isNeedResetTimer) {
_state!.onResumeTimer();
}
}
having same problem here. Any solution anyone?
Have tried these links below, but none of them helped much: https://stackoverflow.com/questions/64822800/null-check-operator-used-on-a-null-value-carousel-flutter https://stackoverflow.com/questions/64278595/null-check-operator-used-on-a-null-value
EDIT: Updating it to the latest version somehow solved it.
Same issue. Related: https://github.com/flutter/flutter/issues/66250 https://stackoverflow.com/questions/64822800/null-check-operator-used-on-a-null-value-carousel-flutter
This worked for me
So I edited scrollposition.dart package
from line 133 @override //double get minScrollExtent => _minScrollExtent!; // double? _minScrollExtent; double get minScrollExtent { if (_minScrollExtent == null) { _minScrollExtent = 0.0; } return double.parse(_minScrollExtent.toString()); }
double? _minScrollExtent;
@override // double get maxScrollExtent => _maxScrollExtent!; // double? _maxScrollExtent; double get maxScrollExtent { if (_maxScrollExtent == null) { _maxScrollExtent = 0.0; } return double.parse(_maxScrollExtent.toString()); }
double? _maxScrollExtent;
also facing the same issue
the same issue
I am facing the same issue here and I am using the latest version is there any update ?