Unverified Commit eb5ae39f authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Skip the drawShadow call in a MergeableMaterial with zero elevation (#89699)

parent 2004afae
...@@ -695,12 +695,14 @@ class _RenderMergeableMaterialListBody extends RenderListBody { ...@@ -695,12 +695,14 @@ class _RenderMergeableMaterialListBody extends RenderListBody {
void _paintShadows(Canvas canvas, Rect rect) { void _paintShadows(Canvas canvas, Rect rect) {
// TODO(ianh): We should interpolate the border radii of the shadows the same way we do those of the visible Material slices. // TODO(ianh): We should interpolate the border radii of the shadows the same way we do those of the visible Material slices.
canvas.drawShadow( if (elevation != 0) {
Path()..addRRect(kMaterialEdges[MaterialType.card]!.toRRect(rect)), canvas.drawShadow(
Colors.black, Path()..addRRect(kMaterialEdges[MaterialType.card]!.toRRect(rect)),
elevation, Colors.black,
true, // occluding object is not (necessarily) opaque elevation,
); true, // occluding object is not (necessarily) opaque
);
}
} }
@override @override
......
...@@ -233,6 +233,36 @@ void main() { ...@@ -233,6 +233,36 @@ void main() {
debugDisableShadows = true; debugDisableShadows = true;
}); });
testWidgets('MergeableMaterial skips shadow for zero elevation', (WidgetTester tester) async {
debugDisableShadows = false;
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: SingleChildScrollView(
child: MergeableMaterial(
elevation: 0,
children: <MergeableMaterialItem>[
MaterialSlice(
key: ValueKey<String>('A'),
child: SizedBox(
width: 100.0,
height: 100.0,
),
),
],
),
),
),
),
);
expect(
find.byType(MergeableMaterial),
isNot(paints..shadow(elevation: 0.0)),
);
debugDisableShadows = true;
});
testWidgets('MergeableMaterial merge gap', (WidgetTester tester) async { testWidgets('MergeableMaterial merge gap', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
......
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