flutter_carousel_slider
flutter_carousel_slider copied to clipboard
Carousels crashs application on swipe with overscroll_indicator Failed assertion notification.metrics.axis == widget.axis
When swiping forward and back really quick, bellow error is thrown and app crashes (when enableInfiniteScroll is false).
Error
════════ Exception caught by animation library ═════════════════════════════════ The following assertion was thrown while notifying listeners for AnimationController: 'package:flutter/src/widgets/overscroll_indicator.dart': Failed assertion: line 243 pos 14: 'notification.metrics.axis == widget.axis': is not true. package:flutter/…/widgets/overscroll_indicator.dart:243 2Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause. In either case, please report this assertion by filing a bug on GitHub: https://github.com/flutter/flutter/issues/new?template=2_bug.md
When the exception was thrown, this was the stack #2 _GlowingOverscrollIndicatorState._handleScrollNotification package:flutter/…/widgets/overscroll_indicator.dart:243 #3 _NotificationElement.onNotification package:flutter/…/widgets/notification_listener.dart:130 #4 _NotificationNode.dispatchNotification package:flutter/…/widgets/framework.dart:3078 #5 _NotificationNode.dispatchNotification package:flutter/…/widgets/framework.dart:3081 #6 _NotificationNode.dispatchNotification package:flutter/…/widgets/framework.dart:3081
This is a reproducible code, just put in anywhere on your code, it will crash your app, if you swipe forward/back quickly.
CarouselSlider.builder(
options: CarouselOptions(
height: 100,
enableInfiniteScroll: false
),
itemCount: 10,
itemBuilder:
(BuildContext context, int index, int pageViewIndex) =>
Container(
width: MediaQuery.of(context).size.width,
child: Text(index.toString())),
)
If I set enableInfiniteScroll to true (or omit it), it works as expected.
CarouselSlider.builder(
options: CarouselOptions(
height: 100,
),
itemCount: 10,
itemBuilder:
(BuildContext context, int index, int pageViewIndex) =>
Container(
width: MediaQuery.of(context).size.width,
child: Text(index.toString())),
)
Hey, @brunodmn as a workaround for now you can set: scrollPhysics: const BouncingScrollPhysics(), in your CarouselOptions.
Hey, @brunodmn as a workaround for now you can set:
scrollPhysics: const BouncingScrollPhysics(),in yourCarouselOptions.
it did work. Thank you!
Hello,
This is also a problem for me, I used the above fix for now but would be great if the user couldn't over or underscroll!
Thanks