getPositionByValue method

double getPositionByValue(
  1. num value
)

Implementation

double getPositionByValue(num value) {
  double offsetValue = 0;
  for (RulerRange config in widget.ranges) {
    if (config.begin <= value && config.end >= value) {
      offsetValue +=
          ((value - config.begin) / config.scale) * _ruleScaleInterval;
      break;
    } else if (value >= config.begin) {
      var totalCount =
          ((config.end - config.begin) / config.scale).truncate();
      offsetValue += totalCount * _ruleScaleInterval;
    }
  }
  return offsetValue;
}