google / flutter.widgets

https://pub.dev/packages/flutter_widgets
BSD 3-Clause "New" or "Revised" License
1.37k stars 474 forks source link

[visibility_detector] onVisibilityChanged not works when scroll faster #529

Closed user97116 closed 5 months ago

jamesderlin commented 5 months ago

Details?

user97116 commented 5 months ago

Expect behaviour -> when it visible onVisibiltyChanged it must called Actual behaviour -> when it visible onVisibiltyChanged not called

onVisibilityChanged callback not working when scrolling faster @jamesderlin

jamesderlin commented 5 months ago

Can you clarify exactly what "not working" means? What behavior did you expect to happen, and what behavior did you actually observe?

user97116 commented 5 months ago

@jamesderlin

jamesderlin commented 5 months ago

I'm not exactly sure what I'm supposed to be observing, but if you're complaining that when scrolling quickly such that a hidden VisibilityDetector momentarily becomes visible, becomes hidden again, and does not fire any callback, then that's intended behavior. (Conversely, if a VisibilityDetector is visible, momentarily becomes hidden, and then becomes visible again, it also will not fire a callback.)

From the README:

Callbacks are not fired immediately on visibility changes. Instead, callbacks are deferred and coalesced such that the callback for each VisibilityDetector will be invoked at most once per VisibilityDetectorController.updateInterval

You can decrease VisibilityDetectorController.updateInterval (the default value is 500 ms), even to 0, although decreasing it too much could negatively impact your application performance.