-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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.