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

Question: How to customize pagination color based on item? #84

Open
DanilKarasev opened this issue Aug 17, 2023 · 1 comment
Open

Question: How to customize pagination color based on item? #84

DanilKarasev opened this issue Aug 17, 2023 · 1 comment

Comments

@DanilKarasev
Copy link

I want to have different colors for each pagination item based on the card content. But since I don't have access to index there - I couldn't find a way to do that. Any suggestions?
Thanks.

@DanilKarasev
Copy link
Author

DanilKarasev commented Aug 17, 2023

Swiper(
      control: kIsWeb && isLargeScreen && itemsCount > 1
          ? const CustomHorizontalSwiperControl(size: 25)
          : null,
      scale: 0.75,
      scrollDirection: Axis.horizontal,
      controller: controller,
      itemCount: itemsCount,
      loop: false,
      pagination: itemsCount > 1
          ? SwiperCustomPagination(
              builder: (BuildContext context, SwiperPluginConfig config) {
                return Align(
                  alignment: Alignment.bottomCenter,
                  child: PageIndicator(
                    count: config.itemCount,
                    controller: config.pageController!,
                    layout: PageIndicatorLayout.SCALE,
                    size: 10,
                    activeColor: Theme.of(context).primaryColor,
                    color: HERE something like index == 1 ? Colors.black :  Theme.of(context).disabledColor,
                    space: 5,
                  ),
                );
              },
            )
          : null,
      itemBuilder: (context, index) {
        return Text('$index');
      },
    );

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

1 participant