Unverified Commit 8b600032 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Fixing constraints.precedingScrollExtent passed to SliverPadding child (#49433)

parent bc8bfb10
......@@ -139,6 +139,7 @@ abstract class RenderSliverEdgeInsetsPadding extends RenderSliver with RenderObj
remainingPaintExtent: constraints.remainingPaintExtent - calculatePaintOffset(constraints, from: 0.0, to: beforePadding),
remainingCacheExtent: constraints.remainingCacheExtent - calculateCacheOffset(constraints, from: 0.0, to: beforePadding),
crossAxisExtent: math.max(0.0, constraints.crossAxisExtent - crossAxisPadding),
precedingScrollExtent: beforePadding + constraints.precedingScrollExtent,
),
parentUsesSize: true,
);
......
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
......@@ -423,4 +424,37 @@ void main() {
const Rect.fromLTRB(0.0, -200.0, 800.0, 200.0),
);
});
testWidgets('SliverPadding includes preceding padding in the precedingScrollExtent provided to child', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/49195
final UniqueKey key = UniqueKey();
await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: CustomScrollView(
slivers: <Widget>[
SliverPadding(
padding: const EdgeInsets.only(top: 30),
sliver: SliverFillRemaining(
hasScrollBody: false,
child: Container(
key: key,
color: Colors.red,
),
)
),
]
),
));
await tester.pump();
// The value of 570 is expected since SliverFillRemaining will fill all of
// the space available to it. In this test, the extent of the viewport is
// 600 pixels. If the SliverPadding widget provides the right constraints
// to SliverFillRemaining, with 30 pixels preceding it, it should only have
// a height of 570.
expect(
tester.renderObject<RenderBox>(find.byKey(key)).size.height,
equals(570),
);
});
}
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