@@ -213,7 +213,9 @@ class Overlay extends StatefulWidget {
213213 const Overlay ({
214214 Key ? key,
215215 this .initialEntries = const < OverlayEntry > [],
216+ this .clipBehavior = Clip .hardEdge,
216217 }) : assert (initialEntries != null ),
218+ assert (clipBehavior != null ),
217219 super (key: key);
218220
219221 /// The entries to include in the overlay initially.
@@ -231,6 +233,11 @@ class Overlay extends StatefulWidget {
231233 /// To remove an entry from an [Overlay] , use [OverlayEntry.remove] .
232234 final List <OverlayEntry > initialEntries;
233235
236+ /// {@macro flutter.widgets.Clip}
237+ ///
238+ /// Defaults to [Clip.hardEdge] , and must not be null.
239+ final Clip clipBehavior;
240+
234241 /// The state from the closest instance of this class that encloses the given context.
235242 ///
236243 /// In debug mode, if the `debugRequiredFor` argument is provided then this
@@ -470,6 +477,7 @@ class OverlayState extends State<Overlay> with TickerProviderStateMixin {
470477 return _Theatre (
471478 skipCount: children.length - onstageCount,
472479 children: children.reversed.toList (growable: false ),
480+ clipBehavior: widget.clipBehavior,
473481 );
474482 }
475483
@@ -490,15 +498,19 @@ class _Theatre extends MultiChildRenderObjectWidget {
490498 _Theatre ({
491499 Key ? key,
492500 this .skipCount = 0 ,
501+ this .clipBehavior = Clip .hardEdge,
493502 List <Widget > children = const < Widget > [],
494503 }) : assert (skipCount != null ),
495504 assert (skipCount >= 0 ),
496505 assert (children != null ),
497506 assert (children.length >= skipCount),
507+ assert (clipBehavior != null ),
498508 super (key: key, children: children);
499509
500510 final int skipCount;
501511
512+ final Clip clipBehavior;
513+
502514 @override
503515 _TheatreElement createElement () => _TheatreElement (this );
504516
@@ -507,14 +519,16 @@ class _Theatre extends MultiChildRenderObjectWidget {
507519 return _RenderTheatre (
508520 skipCount: skipCount,
509521 textDirection: Directionality .of (context)! ,
522+ clipBehavior: clipBehavior,
510523 );
511524 }
512525
513526 @override
514527 void updateRenderObject (BuildContext context, _RenderTheatre renderObject) {
515528 renderObject
516529 ..skipCount = skipCount
517- ..textDirection = Directionality .of (context)! ;
530+ ..textDirection = Directionality .of (context)!
531+ ..clipBehavior = clipBehavior;
518532 }
519533
520534 @override
@@ -545,11 +559,14 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
545559 List <RenderBox >? children,
546560 required TextDirection textDirection,
547561 int skipCount = 0 ,
562+ Clip clipBehavior = Clip .hardEdge,
548563 }) : assert (skipCount != null ),
549564 assert (skipCount >= 0 ),
550565 assert (textDirection != null ),
566+ assert (clipBehavior != null ),
551567 _textDirection = textDirection,
552- _skipCount = skipCount {
568+ _skipCount = skipCount,
569+ _clipBehavior = clipBehavior {
553570 addAll (children);
554571 }
555572
@@ -593,6 +610,20 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
593610 }
594611 }
595612
613+ /// {@macro flutter.widgets.Clip}
614+ ///
615+ /// Defaults to [Clip.hardEdge] , and must not be null.
616+ Clip get clipBehavior => _clipBehavior;
617+ Clip _clipBehavior = Clip .hardEdge;
618+ set clipBehavior (Clip value) {
619+ assert (value != null );
620+ if (value != _clipBehavior) {
621+ _clipBehavior = value;
622+ markNeedsPaint ();
623+ markNeedsSemanticsUpdate ();
624+ }
625+ }
626+
596627 RenderBox ? get _firstOnstageChild {
597628 if (skipCount == super .childCount) {
598629 return null ;
@@ -724,8 +755,8 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
724755
725756 @override
726757 void paint (PaintingContext context, Offset offset) {
727- if (_hasVisualOverflow) {
728- context.pushClipRect (needsCompositing, offset, Offset .zero & size, paintStack);
758+ if (_hasVisualOverflow && clipBehavior != Clip .none ) {
759+ context.pushClipRect (needsCompositing, offset, Offset .zero & size, paintStack, clipBehavior : clipBehavior );
729760 } else {
730761 paintStack (context, offset);
731762 }
0 commit comments