From 73428160844c2c52a959aa74ebf967dd5b6ded7b Mon Sep 17 00:00:00 2001 From: jslavitz Date: Wed, 7 Nov 2018 12:27:08 -0800 Subject: [PATCH] Adds fix for double comparison error (#24026) * adds fix for rounding error --- packages/flutter/lib/src/rendering/sliver.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/rendering/sliver.dart b/packages/flutter/lib/src/rendering/sliver.dart index 4fd7c4dcd3..5b4348a797 100644 --- a/packages/flutter/lib/src/rendering/sliver.dart +++ b/packages/flutter/lib/src/rendering/sliver.dart @@ -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) +