getRulerScaleValue method
获取尺子的刻度值
Implementation
num getRulerScaleValue(int index) {
num rulerScaleValue = 0;
RulerRange? currentConfig;
for (RulerRange config in widget.ranges) {
currentConfig = config;
if (currentConfig == widget.ranges.last) {
break;
}
var totalCount = ((config.end - config.begin) / config.scale).truncate();
if (index <= totalCount) {
break;
} else {
index -= totalCount;
}
}
rulerScaleValue = index * currentConfig!.scale + currentConfig!.begin;
return rulerScaleValue;
}