File tree Expand file tree Collapse file tree 2 files changed +42
-11
lines changed Expand file tree Collapse file tree 2 files changed +42
-11
lines changed Original file line number Diff line number Diff line change @@ -397,6 +397,17 @@ class Container extends StatelessWidget {
397397 if (color != null )
398398 current = ColoredBox (color: color, child: current);
399399
400+ if (clipBehavior != Clip .none) {
401+ current = ClipPath (
402+ clipper: _DecorationClipper (
403+ textDirection: Directionality .of (context),
404+ decoration: decoration
405+ ),
406+ clipBehavior: clipBehavior,
407+ child: current,
408+ );
409+ }
410+
400411 if (decoration != null )
401412 current = DecoratedBox (decoration: decoration, child: current);
402413
@@ -417,17 +428,6 @@ class Container extends StatelessWidget {
417428 if (transform != null )
418429 current = Transform (transform: transform, child: current);
419430
420- if (clipBehavior != Clip .none) {
421- current = ClipPath (
422- clipper: _DecorationClipper (
423- textDirection: Directionality .of (context),
424- decoration: decoration
425- ),
426- clipBehavior: clipBehavior,
427- child: current,
428- );
429- }
430-
431431 return current;
432432 }
433433
Original file line number Diff line number Diff line change @@ -555,6 +555,37 @@ void main() {
555555 await tester.tap (find.byType (Container ));
556556 expect (tapped, false );
557557 });
558+
559+ testWidgets ('using clipBehaviour and shadow, should not clip the shadow' , (WidgetTester tester) async {
560+ final Container container = Container (
561+ clipBehavior: Clip .hardEdge,
562+ decoration: BoxDecoration (
563+ borderRadius: BorderRadius .circular (30 ),
564+ color: Colors .red,
565+ boxShadow: const < BoxShadow > [
566+ BoxShadow (
567+ color: Colors .blue,
568+ offset: Offset .zero,
569+ spreadRadius: 10 ,
570+ blurRadius: 20.0 ,
571+ ),
572+ ]),
573+ child: const SizedBox (width: 50 , height: 50 ),
574+ );
575+
576+ await tester.pumpWidget (
577+ RepaintBoundary (
578+ child: Padding (
579+ padding: const EdgeInsets .all (30.0 ),
580+ child: container,
581+ )),
582+ );
583+
584+ await expectLater (
585+ find.byType (RepaintBoundary ),
586+ matchesGoldenFile ('container.clipBehaviour.with.shadow.png' ),
587+ );
588+ });
558589}
559590
560591class _MockPaintingContext extends Fake implements PaintingContext {
You can’t perform that action at this time.
0 commit comments