Revert "Fix sliver geometry assert (#47027)" (#47390)

This reverts commit 117dfaf2871908d55f73e390c6a3ce4b70010fc8.
This commit is contained in:
Lau Ching Jun 2019-12-18 17:02:11 -08:00 committed by GitHub
parent c281369356
commit f32dee6e30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 61 deletions

View File

@ -1211,17 +1211,17 @@ abstract class RenderSliver extends RenderObject {
} }
)); ));
assert(() { assert(() {
if (geometry.paintOrigin + geometry.paintExtent > constraints.remainingPaintExtent) { if (geometry.paintExtent > constraints.remainingPaintExtent) {
throw FlutterError.fromParts(<DiagnosticsNode>[ throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('SliverGeometry has a paintOffset that exceeds the remainingPaintExtent from the constraints.'), ErrorSummary('SliverGeometry has a paintOffset that exceeds the remainingPaintExtent from the constraints.'),
describeForError('The render object whose geometry violates the constraints is the following'), describeForError('The render object whose geometry violates the constraints is the following'),
..._debugCompareFloats( ..._debugCompareFloats(
'remainingPaintExtent', constraints.remainingPaintExtent, 'remainingPaintExtent', constraints.remainingPaintExtent,
'paintOrigin + paintExtent', geometry.paintOrigin + geometry.paintExtent, 'paintExtent', geometry.paintExtent,
), ),
ErrorDescription( ErrorDescription(
'The paintOrigin and paintExtent must cause the child sliver to paint ' 'The paintExtent must cause the child sliver to paint within the viewport, and so '
'within the viewport, and so cannot exceed the remainingPaintExtent.', 'cannot exceed the remainingPaintExtent.',
), ),
]); ]);
} }

View File

@ -373,15 +373,14 @@ abstract class RenderSliverPinnedPersistentHeader extends RenderSliverPersistent
final bool overlapsContent = constraints.overlap > 0.0; final bool overlapsContent = constraints.overlap > 0.0;
excludeFromSemanticsScrolling = overlapsContent || (constraints.scrollOffset > maxExtent - minExtent); excludeFromSemanticsScrolling = overlapsContent || (constraints.scrollOffset > maxExtent - minExtent);
layoutChild(constraints.scrollOffset, maxExtent, overlapsContent: overlapsContent); layoutChild(constraints.scrollOffset, maxExtent, overlapsContent: overlapsContent);
final double effectiveRemainingPaintExtent = math.max(0, constraints.remainingPaintExtent - constraints.overlap); final double layoutExtent = (maxExtent - constraints.scrollOffset).clamp(0.0, constraints.remainingPaintExtent) as double;
final double layoutExtent = (maxExtent - constraints.scrollOffset).clamp(0.0, effectiveRemainingPaintExtent) as double;
final double stretchOffset = stretchConfiguration != null ? final double stretchOffset = stretchConfiguration != null ?
constraints.overlap.abs() : constraints.overlap.abs() :
0.0; 0.0;
geometry = SliverGeometry( geometry = SliverGeometry(
scrollExtent: maxExtent, scrollExtent: maxExtent,
paintOrigin: constraints.overlap, paintOrigin: constraints.overlap,
paintExtent: math.min(childExtent, effectiveRemainingPaintExtent), paintExtent: math.min(childExtent, constraints.remainingPaintExtent),
layoutExtent: layoutExtent, layoutExtent: layoutExtent,
maxPaintExtent: maxExtent + stretchOffset, maxPaintExtent: maxExtent + stretchOffset,
maxScrollObstructionExtent: minExtent, maxScrollObstructionExtent: minExtent,

View File

@ -1028,30 +1028,6 @@ void main() {
debugDefaultTargetPlatformOverride = null; debugDefaultTargetPlatformOverride = null;
}, },
); );
testWidgets('Should not crash when dragged', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: <Widget>[
CupertinoSliverRefreshControl(
onRefresh: () async => Future<void>.delayed(const Duration(days: 2000)),
),
],
),
),
);
await tester.dragFrom(const Offset(100, 10), const Offset(0.0, 50.0), touchSlopY: 0);
await tester.pump();
await tester.dragFrom(const Offset(100, 10), const Offset(0, 500), touchSlopY: 0);
await tester.pump();
expect(tester.takeException(), isNull);
});
}; };
final VoidCallback stateMachineTestGroup = () { final VoidCallback stateMachineTestGroup = () {
@ -1489,36 +1465,6 @@ void main() {
// Test the internal state machine directly to make sure the UI aren't just // Test the internal state machine directly to make sure the UI aren't just
// correct by coincidence. // correct by coincidence.
group('state machine test short list', stateMachineTestGroup); group('state machine test short list', stateMachineTestGroup);
testWidgets(
'Does not crash when paintExtent > remainingPaintExtent',
(WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/46871.
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: <Widget>[
const CupertinoSliverRefreshControl(),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) => const SizedBox(height: 100),
childCount: 20,
),
),
],
),
),
);
// Drag the content down far enough so that
// geometry.paintExent > constraints.maxPaintExtent
await tester.dragFrom(const Offset(10, 10), const Offset(0, 500));
await tester.pump();
expect(tester.takeException(), isNull);
});
} }
class MockHelper extends Mock { class MockHelper extends Mock {