calculateCurrentPosition function
Implementation
double calculateCurrentPosition(int sourceIndex, int targetIndex, double progress, double totalWidth, {double indicatorWidth = 20}) {
var targetPosition = calculateIndexPosition(targetIndex, totalWidth, indicatorWidth: indicatorWidth);
var sourcePosition = calculateIndexPosition(sourceIndex, totalWidth, indicatorWidth: indicatorWidth);
var distance = (targetPosition - sourcePosition).abs();
var passedDistance = distance * progress;
return targetPosition > sourcePosition ?
sourcePosition + passedDistance
: sourcePosition - passedDistance;
}