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 {
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.
canvas.drawShadow(
Path()..addRRect(kMaterialEdges[MaterialType.card]!.toRRect(rect)),
Colors.black,
elevation,
true, // occluding object is not (necessarily) opaque
);
if (elevation != 0) {
canvas.drawShadow(
Path()..addRRect(kMaterialEdges[MaterialType.card]!.toRRect(rect)),
Colors.black,
elevation,
true, // occluding object is not (necessarily) opaque
);
}
}
@override
......
......@@ -233,6 +233,36 @@ void main() {
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 {
await tester.pumpWidget(
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