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

SmoothPageIndicator work with CarouselSlider #59

Closed
peterbullmatti opened this issue Sep 3, 2022 · 4 comments
Closed

SmoothPageIndicator work with CarouselSlider #59

peterbullmatti opened this issue Sep 3, 2022 · 4 comments

Comments

@peterbullmatti
Copy link

before SmoothPageIndicator works fine with CarouselSlider since it just needs an activeIndex, but the current version of SmoothPageIndicator need a Pagecontroller, and what I have is a CarouselController, how could I transfer this CarouselController to a pagecontroller?

SmoothPageIndicator(
              controller: _pageController // here I only have a CarouselController
              count: controller.photoFrameList.length + 1,
              effect: WormEffect(
                activeDotColor: AppColors.sadColor,
                dotColor: AppColors.sadColor.withOpacity(0.4),
                dotHeight: 8,
                dotWidth: 8,
                type: WormType.thin,
                // strokeWidth: 5,
              ),
            ),

thank you!

@xjc5205
Copy link

xjc5205 commented Oct 29, 2022

Use a transparent pageView as the middleware. The pageView follows CarouselSlider, and the SmoothPageIndicator follows the pageView

@fly-qp
Copy link

fly-qp commented Nov 21, 2022

Use ValueNotifier in combination with ValueListenableBuilder.
In CarouselSlider just implement onPageChanged like this:

onPageChanged: (int index, reason) => _valueNotifier.value = index

And then you can just use AnimatedSmoothIndicator with activeIndex property like this:

ValueListenableBuilder<int>(
  valueListenable: _valueNotifier,
  builder: (BuildContext context, int index, Widget? child) =>
      AnimatedSmoothIndicator(
            activeIndex: index,
            axisDirection: Axis.horizontal,
            count: images.length,
            onDotClicked: _carouselController.animateToPage))

@Hemang-Sidapara
Copy link

use AnimatedSmoothIndicator instead of SmoothPageIndicator, there no need of any controller just need to pass activeIndex

@github-actions
Copy link

github-actions bot commented Mar 3, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

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

No branches or pull requests

4 participants