From fbc3683b1809252aa7383da50edb578d879f5a9f Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 26 Jan 2021 05:04:03 +0100 Subject: [PATCH] ChoiceChip's default "selected" style in dark mode theme is unreadable #49984 (#74610) --- packages/flutter/lib/src/material/theme_data.dart | 2 +- .../flutter/test/material/chip_theme_test.dart | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index f2ee7cc42e..02fc22716e 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -416,7 +416,7 @@ class ThemeData with Diagnosticable { bottomAppBarTheme ??= const BottomAppBarTheme(); cardTheme ??= const CardTheme(); chipTheme ??= ChipThemeData.fromDefaults( - secondaryColor: primaryColor, + secondaryColor: isDark ? Colors.tealAccent[200]! : primaryColor, brightness: colorScheme.brightness, labelStyle: textTheme.bodyText1!, ); diff --git a/packages/flutter/test/material/chip_theme_test.dart b/packages/flutter/test/material/chip_theme_test.dart index 068c1a5d79..b5d1b40bd9 100644 --- a/packages/flutter/test/material/chip_theme_test.dart +++ b/packages/flutter/test/material/chip_theme_test.dart @@ -61,9 +61,23 @@ void main() { expect(chipTheme.backgroundColor, equals(Colors.black.withAlpha(0x1f))); expect(chipTheme.selectedColor, equals(Colors.black.withAlpha(0x3d))); + expect(chipTheme.secondarySelectedColor, equals(Colors.red.withAlpha(0x3d))); expect(chipTheme.deleteIconColor, equals(Colors.black.withAlpha(0xde))); }); + testWidgets('Chip theme is built by ThemeData with dark mode enabled', (WidgetTester tester) async { + final ThemeData theme = ThemeData( + platform: TargetPlatform.android, + brightness: Brightness.dark, + ); + final ChipThemeData chipTheme = theme.chipTheme; + + expect(chipTheme.backgroundColor, equals(Colors.white.withAlpha(0x1f))); + expect(chipTheme.selectedColor, equals(Colors.white.withAlpha(0x3d))); + expect(chipTheme.secondarySelectedColor, equals(Colors.tealAccent[200]!.withAlpha(0x3d))); + expect(chipTheme.deleteIconColor, equals(Colors.white.withAlpha(0xde))); + }); + testWidgets('Chip uses ThemeData chip theme if present', (WidgetTester tester) async { final ThemeData theme = ThemeData( platform: TargetPlatform.android,