mirror of
https://github.com/flutter/flutter
synced 2024-10-13 03:32:55 +00:00
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:
parent
a3ba62dcf3
commit
6204eb6445
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue