Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug : scroll position is not set properly when passing initialItem to CustomCarouselScrollController #7

Open
giboin opened this issue Jun 20, 2024 · 1 comment

Comments

@giboin
Copy link

giboin commented Jun 20, 2024

Describe the bug

When I specify an initialItem other than 0 to the controller of the slider, it shows the right item selected, but the scroll stays at 0, like if the selected item was the first one
Then if we move a bit the slider after it was created, it immediately jumps to the position where it should have been

Steps to Reproduce

  • open the file record_box_view.dart in the example of the package
  • in the _buildCarousel method, in the CustomCarousel widget:
    • remove the loop property (not required but it makes the bug more obvious)
    • add controller: CustomCarouselScrollController(initialItem: 4),
  • launch the project and go to the Record Box section
actual behavior expected behavior
same thing than if you don't pass any controller to the slider the slider's ScrollPosition has the same offset than after calling controller.jumpToItem(4)
simulator_screenshot_D12591DF-A2CF-477F-9E8D-4BE95DC81550 simulator_screenshot_57596F92-889F-4858-BE90-F119A53E9F2A

environement

tested on Android 12
Version 0.1.0+1

Great package by the way, thanks! 🙏

@Kal-Elx
Copy link

Kal-Elx commented Aug 13, 2024

I'm also facing this issue.

My workaround is to not set the initialIndex but instead jump to the item using WidgetsBinding.instance.addPostFrameCallback((_) => _controller.jumpToItem(initialIndex));.

It creates a small glitch though so a proper solution would be nice.

Other than that I'm super happy with this package, thanks a lot 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants