Change SliverGeometry.maxScrollObstructionExtent for RenderSliverFloatingPersistentHeader to match docs (#39263)

RenderSliverFloatingPersistentHeader does not pin to the leading edge of the viewport so the value of maxScrollObstructionExtent in it's SliverGeometry should be 0 per the docs at https://api.flutter.dev/flutter/rendering/SliverGeometry/maxScrollObstructionExtent.html.
This commit is contained in:
Tom Robinson 2019-08-26 15:42:10 -07:00 committed by GitHub
parent a3ba62dcf3
commit 6204eb6445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View file

@ -415,7 +415,6 @@ abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersiste
paintExtent: paintExtent.clamp(0.0, constraints.remainingPaintExtent),
layoutExtent: layoutExtent.clamp(0.0, constraints.remainingPaintExtent),
maxPaintExtent: maxExtent,
maxScrollObstructionExtent: maxExtent,
hasVisualOverflow: true, // Conservatively say we do have overflow to avoid complexity.
);
return math.min(0.0, paintExtent - childExtent);

View file

@ -0,0 +1,39 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart';
import 'rendering_tester.dart';
void main() {
// Regression test for https://github.com/flutter/flutter/issues/35426.
test('RenderSliverFloatingPersistentHeader maxScrollObstructionExtent is 0', () {
final TestRenderSliverFloatingPersistentHeader header = TestRenderSliverFloatingPersistentHeader(child: RenderSizedBox(const Size(400.0, 100.0)));
final RenderViewport root = RenderViewport(
axisDirection: AxisDirection.down,
crossAxisDirection: AxisDirection.right,
offset: ViewportOffset.zero(),
cacheExtent: 0,
children: <RenderSliver>[
header,
],
);
layout(root);
expect(header.geometry.maxScrollObstructionExtent, 0);
});
}
class TestRenderSliverFloatingPersistentHeader extends RenderSliverFloatingPersistentHeader {
TestRenderSliverFloatingPersistentHeader({
RenderBox child,
}) : super(child: child);
@override
double get maxExtent => 200;
@override
double get minExtent => 100;
}