I have a SingleChildScrollView with multiple elements inside it. And some of them are MouseRegion widgets. That listens to hover and starts some animation.
But that kinda messes up, when it gets hovered while scrolling down/up on the SingleChildScrollView widget.
Now I just want to listen to the scroll state. And don't allow to animate while the use is scrolling.
So far I've tried 2 different ways to do that -
Listen to the
ScrollNotificationonNotification: (notification) { if (notification is ScrollStartNotification) { _canPoint = false; } else if (notification is ScrollUpdateNotification) { _canPoint = false; } else if (notification is ScrollEndNotification) { _canPoint = true; } return true; },And use the
_canPointvariable with aIgnorePointerWidget.IgnorePointer( ignoring: !_canPoint, child: ...(Section that listens to MouseHover), ),Check the scroll state of the scrollable of current
context. And not forward with the animation based on that._runAnimation() { final notifier = Scrollable.of(context).position.isScrollingNotifier; if(notifier.value) return; //* Continue with the animation. }
But none of them worked as aspected so far. I was looking for a better way to handle the situation. Thanks in advance.
Add provider package to pubspec.yaml
define ScrollHoverProvider
Wrap your app with the Provider: