fix Container.clipBehaviour, clips the shadow in decoration (#64362)
This commit is contained in:
committed by
GitHub
parent
a864080112
commit
33c619c9ac
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user