From 7d89f2161357d81610e1551816f8c2b24874da2c Mon Sep 17 00:00:00 2001 From: MH Johnson Date: Fri, 25 Sep 2020 10:41:27 -0400 Subject: [PATCH] [Material] Remove opacity from dark theme overlay check (#66596) * Remove opacity from check and add test --- .../lib/src/material/elevation_overlay.dart | 2 +- .../flutter/test/material/material_test.dart | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/elevation_overlay.dart b/packages/flutter/lib/src/material/elevation_overlay.dart index 69eed7942d..26d99375b5 100644 --- a/packages/flutter/lib/src/material/elevation_overlay.dart +++ b/packages/flutter/lib/src/material/elevation_overlay.dart @@ -49,7 +49,7 @@ class ElevationOverlay { if (elevation > 0.0 && theme.applyElevationOverlayColor && theme.brightness == Brightness.dark && - color == theme.colorScheme.surface) { + color.withOpacity(1.0) == theme.colorScheme.surface.withOpacity(1.0)) { return Color.alphaBlend(overlayColor(context, elevation), color); } return color; diff --git a/packages/flutter/test/material/material_test.dart b/packages/flutter/test/material/material_test.dart index 3219418a83..de8ccfbc11 100644 --- a/packages/flutter/test/material/material_test.dart +++ b/packages/flutter/test/material/material_test.dart @@ -343,6 +343,27 @@ void main() { expect(model.color, equals(Colors.cyan)); }); + testWidgets('overlay will apply to materials with a non-opaque surface color', (WidgetTester tester) async { + const Color surfaceColor = Color(0xFF121212); + const Color surfaceColorWithOverlay = Color(0xC6353535); + + await tester.pumpWidget( + Theme( + data: ThemeData( + applyElevationOverlayColor: true, + colorScheme: const ColorScheme.dark(surface: surfaceColor), + ), + child: buildMaterial( + color: surfaceColor.withOpacity(.75), + elevation: 8.0, + ), + ), + ); + + final RenderPhysicalShape model = getModel(tester); + expect(model.color, equals(surfaceColorWithOverlay)); + expect(model.color, isNot(equals(surfaceColor))); + }); }); group('Transparency clipping', () {