flutter_carousel_slider icon indicating copy to clipboard operation
flutter_carousel_slider copied to clipboard

Callback when animateToPage's Future resolves?

Open willhaslett opened this issue 4 years ago • 0 comments

My use case has me wanting to do some work in the app not when onPageChange is fired (which I think is the first frame that is > 50% through the animation?), but rather when the animation is complete.

The context is, each carousel page is relatively expensive to build, and the user could endlessly scroll/move backward and forward (in time in this case), so I'm building the minimum number of pages needed for everything to look right at all times (5), and rebuilding the thing after a page move so that the current page is always in the center of the new set of 5 pages.

It seems that a callback when animateToPage's Future resolves would do just that. Can I get that functionality with the current API, or would I need to hack the source? If it's the latter, this is a feature request.

...Or, is using onPageChange effectively the same thing when it comes to, e.g., rebuilding the carousel? That is, would triggering a rebuild on a CarouselSlider during an animation wait until the animation is over anyway?

willhaslett avatar Feb 27 '21 14:02 willhaslett