Unverified Commit f32dee6e authored by Lau Ching Jun's avatar Lau Ching Jun Committed by GitHub

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

This reverts commit 117dfaf2.
parent c2813693
......@@ -1211,17 +1211,17 @@ abstract class RenderSliver extends RenderObject {
}
));
assert(() {
if (geometry.paintOrigin + geometry.paintExtent > constraints.remainingPaintExtent) {
if (geometry.paintExtent > constraints.remainingPaintExtent) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('SliverGeometry has a paintOffset that exceeds the remainingPaintExtent from the constraints.'),
describeForError('The render object whose geometry violates the constraints is the following'),
..._debugCompareFloats(
'remainingPaintExtent', constraints.remainingPaintExtent,
'paintOrigin + paintExtent', geometry.paintOrigin + geometry.paintExtent,
'paintExtent', geometry.paintExtent,
),
ErrorDescription(
'The paintOrigin and paintExtent must cause the child sliver to paint '
'within the viewport, and so cannot exceed the remainingPaintExtent.',
'The paintExtent must cause the child sliver to paint within the viewport, and so '
'cannot exceed the remainingPaintExtent.',
),
]);
}
......
......@@ -373,15 +373,14 @@ abstract class RenderSliverPinnedPersistentHeader extends RenderSliverPersistent
final bool overlapsContent = constraints.overlap > 0.0;
excludeFromSemanticsScrolling = overlapsContent || (constraints.scrollOffset > maxExtent - minExtent);
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, effectiveRemainingPaintExtent) as double;
final double layoutExtent = (maxExtent - constraints.scrollOffset).clamp(0.0, constraints.remainingPaintExtent) as double;
final double stretchOffset = stretchConfiguration != null ?
constraints.overlap.abs() :
0.0;
geometry = SliverGeometry(
scrollExtent: maxExtent,
paintOrigin: constraints.overlap,
paintExtent: math.min(childExtent, effectiveRemainingPaintExtent),
paintExtent: math.min(childExtent, constraints.remainingPaintExtent),
layoutExtent: layoutExtent,
maxPaintExtent: maxExtent + stretchOffset,
maxScrollObstructionExtent: minExtent,
......
......@@ -1028,30 +1028,6 @@ void main() {
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 = () {
......@@ -1489,36 +1465,6 @@ void main() {
// Test the internal state machine directly to make sure the UI aren't just
// correct by coincidence.
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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment