nixrajput / flutter_carousel_widget

A customizable Flutter carousel widget with infinite scrolling, auto-scrolling, pre-built indicators, expandable widgets, auto-sized child support, and enlarged center page.
https://pub.dev/packages/flutter_carousel_widget
MIT License
39 stars 23 forks source link

[Bug]: initialPage parameter should affect the slide indicators #37

Closed canbi closed 2 months ago

canbi commented 8 months ago

Contact Details

canbiw@icloud.com

What happened?

Given the initialPage parameter in CarouselOptions, the slide indicators always start with index 0.

I extended one of the slide indicators and wrote this and it works as expected:

class ModifiedCircularSlideIndicator extends CircularSlideIndicator {
  const ModifiedCircularSlideIndicator({
    super.itemSpacing,
    super.indicatorRadius,
    super.indicatorBorderWidth,
    super.indicatorBorderColor,
    super.padding,
    super.alignment,
    super.currentIndicatorColor,
    super.indicatorBackgroundColor,
    required this.startIndex,
  });

  final int startIndex;

  @override
  Widget build(int currentPage, double pageDelta, int itemCount) {
    final newCurrentPage = (startIndex + currentPage) % itemCount
    return super.build(newCurrentPage, pageDelta, itemCount);
  }
}

Version

2.2.0

What devices are you seeing the problem on?

Android, iPhone

OS

iOS 16

Relevant log output

No response

Code of Conduct

nixrajput commented 8 months ago

Hi @canbi,

Thank you for raising this issue. It's a bug and I will look into the issue. If you have any questions, please talk about them more. You may also make a PR if you have a tested solution.

Regards, Nikhil

jdbenito-atco commented 5 months ago

Is there an estimated completion time for this? Thanks!