Unverified Commit 33c619c9 authored by Sahand Akbarzadeh's avatar Sahand Akbarzadeh Committed by GitHub

fix Container.clipBehaviour, clips the shadow in decoration (#64362)

parent a8640801
......@@ -397,6 +397,17 @@ class Container extends StatelessWidget {
if (color != null)
current = ColoredBox(color: color, child: current);
if (clipBehavior != Clip.none) {
current = ClipPath(
clipper: _DecorationClipper(
textDirection: Directionality.of(context),
decoration: decoration
),
clipBehavior: clipBehavior,
child: current,
);
}
if (decoration != null)
current = DecoratedBox(decoration: decoration, child: current);
......@@ -417,17 +428,6 @@ class Container extends StatelessWidget {
if (transform != null)
current = Transform(transform: transform, child: current);
if (clipBehavior != Clip.none) {
current = ClipPath(
clipper: _DecorationClipper(
textDirection: Directionality.of(context),
decoration: decoration
),
clipBehavior: clipBehavior,
child: current,
);
}
return current;
}
......
......@@ -555,6 +555,37 @@ void main() {
await tester.tap(find.byType(Container));
expect(tapped, false);
});
testWidgets('using clipBehaviour and shadow, should not clip the shadow', (WidgetTester tester) async {
final Container container = Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.red,
boxShadow: const <BoxShadow>[
BoxShadow(
color: Colors.blue,
offset: Offset.zero,
spreadRadius: 10,
blurRadius: 20.0,
),
]),
child: const SizedBox(width: 50, height: 50),
);
await tester.pumpWidget(
RepaintBoundary(
child: Padding(
padding: const EdgeInsets.all(30.0),
child: container,
)),
);
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile('container.clipBehaviour.with.shadow.png'),
);
});
}
class _MockPaintingContext extends Fake implements PaintingContext {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment