hitTestDots method

  1. @override
int hitTestDots(
  1. double dx,
  2. int count,
  3. double current
)
override

Returns the index of the section that contains dx.

Sections or hit-targets are calculated differently in some effects

Implementation

@override
int hitTestDots(double dx, int count, double current) {
  var anchor = -spacing / 2;
  for (var index = 0; index < count; index++) {
    var widthBound =
        (index == current ? (dotWidth * expansionFactor) : dotWidth) +
            spacing;
    if (dx <= (anchor += widthBound)) {
      return index;
    }
  }
  return -1;
}