Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Overlay always applies clip #113770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions packages/flutter/lib/src/widgets/overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,6 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
addAll(children);
}

bool _hasVisualOverflow = false;

@override
void setupParentData(RenderBox child) {
if (child.parentData is! StackParentData) {
Expand Down Expand Up @@ -836,8 +834,6 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox

@override
void performLayout() {
_hasVisualOverflow = false;

if (_onstageChildCount == 0) {
return;
}
Expand All @@ -856,7 +852,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
child.layout(nonPositionedConstraints, parentUsesSize: true);
childParentData.offset = _resolvedAlignment!.alongOffset(size - child.size as Offset);
} else {
_hasVisualOverflow = RenderStack.layoutPositionedChild(child, childParentData, size, _resolvedAlignment!) || _hasVisualOverflow;
RenderStack.layoutPositionedChild(child, childParentData, size, _resolvedAlignment!);
}

assert(child.parentData == childParentData);
Expand Down Expand Up @@ -898,7 +894,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox

@override
void paint(PaintingContext context, Offset offset) {
if (_hasVisualOverflow && clipBehavior != Clip.none) {
if (clipBehavior != Clip.none) {
_clipRectLayer.layer = context.pushClipRect(
needsCompositing,
offset,
Expand Down Expand Up @@ -939,7 +935,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
case Clip.hardEdge:
case Clip.antiAlias:
case Clip.antiAliasWithSaveLayer:
return _hasVisualOverflow ? Offset.zero & size : null;
return Offset.zero & size;
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/cupertino/action_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ void main() {
);

await tester.tap(find.text('Go'));
await tester.pump();
await tester.pumpAndSettle();

expect(
semantics,
Expand Down
23 changes: 23 additions & 0 deletions packages/flutter/test/widgets/overlay_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

import '../rendering/mock_canvas.dart';
import 'semantics_tester.dart';

void main() {
Expand Down Expand Up @@ -1119,6 +1120,28 @@ void main() {
}
});

testWidgets('Overlay always applies clip', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Overlay(
initialEntries: <OverlayEntry>[
OverlayEntry(
builder: (BuildContext context) => Positioned(left: 10, right: 10, child: Container()),
),
],
),
),
);
final RenderObject renderObject = tester.renderObject(find.byType(Overlay));
// ignore: avoid_dynamic_calls
expect((renderObject as dynamic).paint, paints
..save()
..clipRect(rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 600.0))
..restore(),
);
});

group('OverlayEntry listenable', () {
final GlobalKey overlayKey = GlobalKey();
final Widget emptyOverlay = Directionality(
Expand Down