When a widget equipped with ScrollLoopAutoScroll is mounted and then immediately disposed, an error is triggered due to the scroll controller being accessed after the widget's disposal.
After investigating, I discovered that there's an intrinsic delay before initiating the scrolling. If the widget is mounted and subsequently unmounted prior to the culmination of this delay, it results in an error.
Error Message:
flutter: 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 105 pos 12: '_positions.isNotEmpty': ScrollController not attached to any scroll views.
Proposed Solution
To prevent this error, it's pivotal to ensure that the widget is still mounted before activating the animation within the scroll controller's listener. Here's an example:
scrollController.addListener(() async {
if (widget.enableScrollInput) {
if (animationController.isAnimating) {
animationController.stop();
} else {
await Future.delayed(widget.delayAfterScrollInput);
if (mounted) {
animationHandler();
}
}
}
});
I will submit a pull request addressing this issue shortly.
Problem
When a widget equipped with ScrollLoopAutoScroll is mounted and then immediately disposed, an error is triggered due to the scroll controller being accessed after the widget's disposal.
After investigating, I discovered that there's an intrinsic delay before initiating the scrolling. If the widget is mounted and subsequently unmounted prior to the culmination of this delay, it results in an error.
Error Message:
Proposed Solution
To prevent this error, it's pivotal to ensure that the widget is still mounted before activating the animation within the scroll controller's listener. Here's an example:
I will submit a pull request addressing this issue shortly.