Adds fix for double comparison error (#24026)

* adds fix for rounding error
This commit is contained in:
jslavitz
2018-11-07 12:27:08 -08:00
committed by GitHub
parent 3d01e89e7a
commit 7342816084

View File

@@ -656,6 +656,8 @@ class SliverGeometry extends Diagnosticable {
/// * [RenderViewport.cacheExtent] for a description of a viewport's cache area.
final double cacheExtent;
static const double _epsilon = 1e-10;
/// Asserts that this geometry is internally consistent.
///
/// Does nothing if asserts are disabled. Always returns true.
@@ -686,7 +688,9 @@ class SliverGeometry extends Diagnosticable {
);
}
verify(maxPaintExtent != null, 'The "maxPaintExtent" is null.');
if (maxPaintExtent < paintExtent) {
// If the paintExtent is slightly more than the maxPaintExtent, but the difference is still less
// than epsilon, we will not throw the assert below.
if (paintExtent - maxPaintExtent > _epsilon) {
verify(false,
'The "maxPaintExtent" is less than the "paintExtent".\n' +
_debugCompareFloats('maxPaintExtent', maxPaintExtent, 'paintExtent', paintExtent) +