Due to floating-point rounding, some sequence of updates to individual extents via ExtentList.setExtent can make total extent value to be below zero. Here's a simplified code that simulates the changes to two extents by same values (imagine two slivers changing sizes simultaneously):
void main() {
final el = ExtentList();
for (final newExtent in [31.500089999999997, 22.500045, 15.750045000000004, 9.000045000000004, 0.0]) {
el.updateExtents(newExtent);
print(el.totalExtent);
}
}
class ExtentList {
double totalExtent = 108.0;
final extents = [54.0, 54.0];
void updateExtents(double newExtent) {
for (int index = 0; index < extents.length; index++) {
totalExtent -= extents[index];
extents[index] = newExtent;
totalExtent += newExtent;
}
}
}
The totalExtent after each call to updateExtents() are as follows:
Due to floating-point rounding, some sequence of updates to individual extents via
ExtentList.setExtent
can make total extent value to be below zero. Here's a simplified code that simulates the changes to two extents by same values (imagine two slivers changing sizes simultaneously):The totalExtent after each call to updateExtents() are as follows: