isRangesChanged method
Checks if the ranges of the UnitRuler have changed compared to the old widget.
This method compares the current configuration of the ruler with the previous configuration
(provided via oldWidget
). It returns true if the ranges (e.g., the unit intervals or scale) have
changed, indicating that the widget needs to be rebuilt or updated.
Implementation
bool isRangesChanged(UnitRuler oldWidget) {
if (oldWidget.scaleUnit.scaleIntervals.length !=
widget.scaleUnit.scaleIntervals.length) {
return true;
}
if (widget.scaleUnit.scaleIntervals.isEmpty) return false;
for (int i = 0; i < widget.scaleUnit.scaleIntervals.length; i++) {
ScaleIntervals oldRange = oldWidget.scaleUnit.scaleIntervals[i];
ScaleIntervals range = widget.scaleUnit.scaleIntervals[i];
if (oldRange.begin != range.begin ||
oldRange.end != range.end ||
oldRange.scale != range.scale) {
return true;
}
}
return false;
}