Repository navigation
[Flutter Web] NotificationListener ScrollNotification is bugged with SingleChildScrollView (All possible ScrollNotifications registering on each frame) #44732
Description
I am trying to track the ScrollNotification within a SingleChildScrollView in order to implement some behavior when reaching the bottom of the widget and for some reason I am getting all possible ScrollNotification states on every frame.
This is the structure of the application.
Scaffold(
body: NotificationListener(
onNotification: (scrollNotification) {
print(scrollNotification); // Error can be noticed with this line
return true; // needed to return bool. does not change result
},
child: SingleChildScrollView(
child: Column(
children:
[
// widgets
],
),
),
),
),On the first line of the function that is located at the onNotification property, I am printing out the scroll notification in order to track when the SingleChildScrollView updates and when it reaches the bottom of the widget when scrolling.
Instead of printing one ScrollEndNotification when reaching the bottom of the SingleChildScrollView, what happens instead is that all possible states of the ScrollNotification are printed on each frame.
This is what logs to the console:
ScrollStartNotification(depth: 2 (remote), FixedScrollMetrics(0.8..[337.6]..0.0))
ScrollUpdateNotification(depth: 2 (remote), FixedScrollMetrics(0.8..[337.6]..0.0), scrollDelta: 0.8181512605042371)
ScrollEndNotification(depth: 2 (remote), FixedScrollMetrics(0.8..[337.6]..0.0))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(204.0..[998.0]..761.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(204.0..[998.0]..761.4), scrollDelta: 119)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(204.0..[998.0]..761.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(223.0..[998.0]..742.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(223.0..[998.0]..742.4), scrollDelta: 19)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(223.0..[998.0]..742.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(323.0..[998.0]..642.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(323.0..[998.0]..642.4), scrollDelta: 100)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(323.0..[998.0]..642.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(351.0..[998.0]..614.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(351.0..[998.0]..614.4), scrollDelta: 28)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(351.0..[998.0]..614.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(397.0..[998.0]..568.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(397.0..[998.0]..568.4), scrollDelta: 46)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(397.0..[998.0]..568.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(414.0..[998.0]..551.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(414.0..[998.0]..551.4), scrollDelta: 17)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(414.0..[998.0]..551.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(429.0..[998.0]..536.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(429.0..[998.0]..536.4), scrollDelta: 15)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(429.0..[998.0]..536.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(448.0..[998.0]..517.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(448.0..[998.0]..517.4), scrollDelta: 19)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(448.0..[998.0]..517.4))
ScrollStartNotification(depth: 2 (remote), FixedScrollMetrics(0.8..[337.6]..0.0))
ScrollUpdateNotification(depth: 2 (remote), FixedScrollMetrics(0.8..[337.6]..0.0), scrollDelta: 0.8181512605042371)
ScrollEndNotification(depth: 2 (remote), FixedScrollMetrics(0.8..[337.6]..0.0))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(474.0..[998.0]..491.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(474.0..[998.0]..491.4), scrollDelta: 26)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(474.0..[998.0]..491.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(480.0..[998.0]..485.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(480.0..[998.0]..485.4), scrollDelta: 6)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(480.0..[998.0]..485.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(488.0..[998.0]..477.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(488.0..[998.0]..477.4), scrollDelta: 8)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(488.0..[998.0]..477.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(489.0..[998.0]..476.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(489.0..[998.0]..476.4), scrollDelta: 1)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(489.0..[998.0]..476.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(502.0..[998.0]..463.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(502.0..[998.0]..463.4), scrollDelta: 13)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(502.0..[998.0]..463.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(511.0..[998.0]..454.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(511.0..[998.0]..454.4), scrollDelta: 9)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(511.0..[998.0]..454.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(545.0..[998.0]..420.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(545.0..[998.0]..420.4), scrollDelta: 34)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(545.0..[998.0]..420.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(586.0..[998.0]..379.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(586.0..[998.0]..379.4), scrollDelta: 41)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(586.0..[998.0]..379.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(630.0..[998.0]..335.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(630.0..[998.0]..335.4), scrollDelta: 44)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(630.0..[998.0]..335.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(650.0..[998.0]..315.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(650.0..[998.0]..315.4), scrollDelta: 20)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(650.0..[998.0]..315.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(686.0..[998.0]..279.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(686.0..[998.0]..279.4), scrollDelta: 36)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(686.0..[998.0]..279.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(793.0..[998.0]..172.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(793.0..[998.0]..172.4), scrollDelta: 107)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(793.0..[998.0]..172.4))
ScrollStartNotification(depth: 2 (remote), FixedScrollMetrics(0.8..[337.6]..0.0))
ScrollUpdateNotification(depth: 2 (remote), FixedScrollMetrics(0.8..[337.6]..0.0), scrollDelta: 0.8181512605042371)
ScrollEndNotification(depth: 2 (remote), FixedScrollMetrics(0.8..[337.6]..0.0))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(957.0..[998.0]..8.4))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(957.0..[998.0]..8.4), scrollDelta: 164)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(957.0..[998.0]..8.4))
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(965.4..[998.0]..0.0))
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(965.4..[998.0]..0.0), scrollDelta: 8.365546218487225)
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(965.4..[998.0]..0.0))
Instead I should be seeing something like this when at the beginning of the widget:
ScrollStartNotification(depth: 0 (local), FixedScrollMetrics(// misc)
followed by this when scrolling:
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(// misc)
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(// misc)
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(// misc)
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(// misc)
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(// misc)
ScrollUpdateNotification(depth: 0 (local), FixedScrollMetrics(// misc)
...
followed by this when the bottom is reached:
ScrollEndNotification(depth: 0 (local), FixedScrollMetrics(//)
This widget tree is also within a stateful widget and I am currently experiencing this when using Flutter Web.
Activity
[-]NotificationListener scrollNotification is bugged with SingleChildScrollView[/-][+]NotificationListener ScrollNotification is bugged with SingleChildScrollView (All possible ScrollNotifications displaying on each frame)[/+]khari998 commentedon Nov 12, 2019
Here is a sample app for you to test and confirm this bug.
Steps to reproduce
[-]NotificationListener ScrollNotification is bugged with SingleChildScrollView (All possible ScrollNotifications displaying on each frame)[/-][+]NotificationListener ScrollNotification is bugged with SingleChildScrollView (All possible ScrollNotifications registering on each frame)[/+]iapicca commentedon Nov 14, 2019
Hi @khari998
could you please provide your updated
flutter doctor -v?Thank you
khari998 commentedon Nov 14, 2019
flutter doctor -v
flutter run --verbose
khari998 commentedon Nov 19, 2019
Has anyone been able to replicate this with the sample app provided?
iapicca commentedon Nov 21, 2019
Hi @khari998
does this code represent the issue you are describing?
code
Thank you
58 remaining items
khari998 commentedon Sep 5, 2021
It was a mouse scroll action. So this is intended behavior?
I will try this thank you.
Piinks commentedon Sep 7, 2021
Yes, I believe so, but please do let me know how that works for you. :)
andynvt commentedon Sep 23, 2021
I don't know this is correct or not.
I got the same issue with macOS/iOS on
Flutter beta 2.5.0. Then I updatedFlutter beta 2.6.0-Flutter stable 2.5.1. It didn't work.I keep checkout to
Flutter 2.2.3. It was the same.But after I checkout back to
Flutter stable 2.5.1, thenFlutter beta 2.6.0. It works!You guys can try your luck 😄
Edit: I got error in:
CustomScrollView,ListViewand evenSingleChildScrollViewdanagbemava-nc commentedon Nov 3, 2021
@khari998 did trying this comment work out for you?
github-actions commentedon Nov 3, 2021
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.
github-actions commentedon Nov 17, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.