From 0da6f04f07c5644ebad291595b5fbcbde1b9ed52 Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Fri, 26 May 2023 15:33:58 -0700 Subject: [PATCH] Remove references to deprecated `ThemeData.primaryColorBrightness` (#127238) ## Description Removes references to `ThemeData.primaryColorBrightness`, deprecated in https://github.com/flutter/flutter/pull/93396 and subject to remove now because of our [deprecation policy](https://github.com/flutter/flutter/wiki/Tree-hygiene#deprecations). ## Related PRs - https://github.com/flutter/flutter/pull/93396 ## Tests - Removed unneeded tests, removed references. --- .../flutter/lib/src/material/theme_data.dart | 46 +------------------ .../flutter/test/material/app_bar_test.dart | 2 - .../test/material/circle_avatar_test.dart | 10 +--- .../flutter/test/material/snack_bar_test.dart | 1 - .../test/material/theme_data_test.dart | 23 ---------- 5 files changed, 4 insertions(+), 78 deletions(-) diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index 35e77c1bb7..91475735cf 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -307,8 +307,8 @@ class ThemeData with Diagnosticable { VisualDensity? visualDensity, // COLOR // [colorScheme] is the preferred way to configure colors. The other color - // properties (as well as primaryColorBrightness, and primarySwatch) - // will gradually be phased out, see https://github.com/flutter/flutter/issues/91772. + // properties (as well as primarySwatch) will gradually be phased out, see + // https://github.com/flutter/flutter/issues/91772. Brightness? brightness, Color? canvasColor, Color? cardColor, @@ -388,11 +388,6 @@ class ThemeData with Diagnosticable { ToggleButtonsThemeData? toggleButtonsTheme, TooltipThemeData? tooltipTheme, // DEPRECATED (newest deprecations at the bottom) - @Deprecated( - 'No longer used by the framework, please remove any reference to it. ' - 'This feature was deprecated after v2.6.0-11.0.pre.', - ) - Brightness? primaryColorBrightness, @Deprecated( 'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. ' 'This feature was deprecated after v2.13.0-0.0.pre.' @@ -469,7 +464,6 @@ class ThemeData with Diagnosticable { // Default some of the color settings to values from the color scheme primaryColor ??= primarySurfaceColor; - primaryColorBrightness = ThemeData.estimateBrightnessForColor(primarySurfaceColor); canvasColor ??= colorScheme.background; scaffoldBackgroundColor ??= colorScheme.background; bottomAppBarColor ??= colorScheme.surface; @@ -599,7 +593,6 @@ class ThemeData with Diagnosticable { tooltipTheme ??= const TooltipThemeData(); // DEPRECATED (newest deprecations at the bottom) - primaryColorBrightness = estimatedPrimaryColorBrightness; errorColor ??= Colors.red[700]!; backgroundColor ??= isDark ? Colors.grey[700]! : primarySwatch[200]!; bottomAppBarColor ??= colorSchemeSeed != null ? colorScheme.surface : isDark ? Colors.grey[800]! : Colors.white; @@ -696,7 +689,6 @@ class ThemeData with Diagnosticable { toggleButtonsTheme: toggleButtonsTheme, tooltipTheme: tooltipTheme, // DEPRECATED (newest deprecations at the bottom) - primaryColorBrightness: primaryColorBrightness, androidOverscrollIndicator: androidOverscrollIndicator, toggleableActiveColor: toggleableActiveColor, selectedRowColor: selectedRowColor, @@ -808,11 +800,6 @@ class ThemeData with Diagnosticable { required this.toggleButtonsTheme, required this.tooltipTheme, // DEPRECATED (newest deprecations at the bottom) - @Deprecated( - 'No longer used by the framework, please remove any reference to it. ' - 'This feature was deprecated after v2.6.0-11.0.pre.', - ) - Brightness? primaryColorBrightness, @Deprecated( 'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. ' 'This feature was deprecated after v2.13.0-0.0.pre.' @@ -848,7 +835,6 @@ class ThemeData with Diagnosticable { }) : // DEPRECATED (newest deprecations at the bottom) // should not be `required`, use getter pattern to avoid breakages. - _primaryColorBrightness = primaryColorBrightness, _toggleableActiveColor = toggleableActiveColor, _selectedRowColor = selectedRowColor, _errorColor = errorColor, @@ -856,7 +842,6 @@ class ThemeData with Diagnosticable { _bottomAppBarColor = bottomAppBarColor, assert(toggleableActiveColor != null), // DEPRECATED (newest deprecations at the bottom) - assert(primaryColorBrightness != null), assert(errorColor != null), assert(backgroundColor != null); @@ -903,7 +888,6 @@ class ThemeData with Diagnosticable { colorScheme: colorScheme, brightness: colorScheme.brightness, primaryColor: primarySurfaceColor, - primaryColorBrightness: ThemeData.estimateBrightnessForColor(primarySurfaceColor), canvasColor: colorScheme.background, scaffoldBackgroundColor: colorScheme.background, bottomAppBarColor: colorScheme.surface, @@ -1524,22 +1508,6 @@ class ThemeData with Diagnosticable { // DEPRECATED (newest deprecations at the bottom) - /// Obsolete property that was originally used to determine the color - /// of text and icons placed on top of the primary color (e.g. toolbar text). - /// - /// The material library no longer uses this property. The [appBarTheme] can - /// be used to configure the appearance of [AppBar]s. The appearance of - /// Keyboards for [TextField]s now uses the overall theme's - /// [ThemeData.brightness] and can also be customized with - /// [TextField.keyboardAppearance]. The brightness of any color can be found - /// with [ThemeData.estimateBrightnessForColor]. - @Deprecated( - 'No longer used by the framework, please remove any reference to it. ' - 'This feature was deprecated after v2.6.0-11.0.pre.', - ) - Brightness get primaryColorBrightness => _primaryColorBrightness!; - final Brightness? _primaryColorBrightness; - /// Specifies which overscroll indicator to use on [TargetPlatform.android]. /// /// When null, the default value of @@ -1696,11 +1664,6 @@ class ThemeData with Diagnosticable { ToggleButtonsThemeData? toggleButtonsTheme, TooltipThemeData? tooltipTheme, // DEPRECATED (newest deprecations at the bottom) - @Deprecated( - 'No longer used by the framework, please remove any reference to it. ' - 'This feature was deprecated after v2.6.0-11.0.pre.', - ) - Brightness? primaryColorBrightness, @Deprecated( 'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. ' 'This feature was deprecated after v2.13.0-0.0.pre.' @@ -1827,7 +1790,6 @@ class ThemeData with Diagnosticable { toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme, tooltipTheme: tooltipTheme ?? this.tooltipTheme, // DEPRECATED (newest deprecations at the bottom) - primaryColorBrightness: primaryColorBrightness ?? _primaryColorBrightness, androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator, toggleableActiveColor: toggleableActiveColor ?? _toggleableActiveColor, selectedRowColor: selectedRowColor ?? _selectedRowColor, @@ -2022,7 +1984,6 @@ class ThemeData with Diagnosticable { toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t)!, tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t)!, // DEPRECATED (newest deprecations at the bottom) - primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness, androidOverscrollIndicator:t < 0.5 ? a.androidOverscrollIndicator : b.androidOverscrollIndicator, toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t), selectedRowColor: Color.lerp(a.selectedRowColor, b.selectedRowColor, t), @@ -2129,7 +2090,6 @@ class ThemeData with Diagnosticable { other.toggleButtonsTheme == toggleButtonsTheme && other.tooltipTheme == tooltipTheme && // DEPRECATED (newest deprecations at the bottom) - other.primaryColorBrightness == primaryColorBrightness && other.androidOverscrollIndicator == androidOverscrollIndicator && other.toggleableActiveColor == toggleableActiveColor && other.selectedRowColor == selectedRowColor && @@ -2233,7 +2193,6 @@ class ThemeData with Diagnosticable { toggleButtonsTheme, tooltipTheme, // DEPRECATED (newest deprecations at the bottom) - primaryColorBrightness, androidOverscrollIndicator, toggleableActiveColor, selectedRowColor, @@ -2339,7 +2298,6 @@ class ThemeData with Diagnosticable { properties.add(DiagnosticsProperty('toggleButtonsTheme', toggleButtonsTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('tooltipTheme', tooltipTheme, level: DiagnosticLevel.debug)); // DEPRECATED (newest deprecations at the bottom) - properties.add(EnumProperty('primaryColorBrightness', primaryColorBrightness, defaultValue: defaultData.primaryColorBrightness, level: DiagnosticLevel.debug)); properties.add(EnumProperty('androidOverscrollIndicator', androidOverscrollIndicator, defaultValue: null, level: DiagnosticLevel.debug)); properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor, level: DiagnosticLevel.debug)); properties.add(ColorProperty('selectedRowColor', selectedRowColor, defaultValue: defaultData.selectedRowColor, level: DiagnosticLevel.debug)); diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 66e4fd4005..36a8b20bda 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -2455,7 +2455,6 @@ void main() { ), )); - expect(darkTheme.primaryColorBrightness, Brightness.dark); expect(darkTheme.colorScheme.brightness, Brightness.dark); expect(SystemChrome.latestStyle, const SystemUiOverlayStyle( statusBarBrightness: Brightness.dark, @@ -2476,7 +2475,6 @@ void main() { ), ); - expect(lightTheme.primaryColorBrightness, Brightness.light); expect(lightTheme.colorScheme.brightness, Brightness.light); expect(SystemChrome.latestStyle, const SystemUiOverlayStyle( statusBarBrightness: Brightness.light, diff --git a/packages/flutter/test/material/circle_avatar_test.dart b/packages/flutter/test/material/circle_avatar_test.dart index fb737b3053..287792981b 100644 --- a/packages/flutter/test/material/circle_avatar_test.dart +++ b/packages/flutter/test/material/circle_avatar_test.dart @@ -286,10 +286,7 @@ void main() { // is turned on by default, these tests can be removed. testWidgets('CircleAvatar default colors with light theme', (WidgetTester tester) async { - final ThemeData theme = ThemeData( - primaryColor: Colors.grey.shade100, - primaryColorBrightness: Brightness.light, - ); + final ThemeData theme = ThemeData(primaryColor: Colors.grey.shade100); await tester.pumpWidget( wrap( child: Theme( @@ -311,10 +308,7 @@ void main() { }); testWidgets('CircleAvatar default colors with dark theme', (WidgetTester tester) async { - final ThemeData theme = ThemeData( - primaryColor: Colors.grey.shade800, - primaryColorBrightness: Brightness.dark, - ); + final ThemeData theme = ThemeData(primaryColor: Colors.grey.shade800); await tester.pumpWidget( wrap( child: Theme( diff --git a/packages/flutter/test/material/snack_bar_test.dart b/packages/flutter/test/material/snack_bar_test.dart index d67c91f1ec..50dec4950a 100644 --- a/packages/flutter/test/material/snack_bar_test.dart +++ b/packages/flutter/test/material/snack_bar_test.dart @@ -445,7 +445,6 @@ void main() { final ThemeData theme = ThemeData.light().copyWith( visualDensity: VisualDensity.standard, primaryColor: Colors.black, - primaryColorBrightness: Brightness.dark, primaryColorLight: Colors.black, primaryColorDark: Colors.black, canvasColor: Colors.black, diff --git a/packages/flutter/test/material/theme_data_test.dart b/packages/flutter/test/material/theme_data_test.dart index 46aad3cb18..ce77262ad0 100644 --- a/packages/flutter/test/material/theme_data_test.dart +++ b/packages/flutter/test/material/theme_data_test.dart @@ -125,19 +125,6 @@ void main() { expect(ThemeData.estimateBrightnessForColor(Colors.indigo), equals(Brightness.dark)); }); - test('Can estimate brightness - indirectly', () { - expect(ThemeData(primaryColor: Colors.white).primaryColorBrightness, equals(Brightness.light)); - expect(ThemeData(primaryColor: Colors.black).primaryColorBrightness, equals(Brightness.dark)); - expect(ThemeData(primaryColor: Colors.blue).primaryColorBrightness, equals(Brightness.dark)); - expect(ThemeData(primaryColor: Colors.yellow).primaryColorBrightness, equals(Brightness.light)); - expect(ThemeData(primaryColor: Colors.deepOrange).primaryColorBrightness, equals(Brightness.dark)); - expect(ThemeData(primaryColor: Colors.orange).primaryColorBrightness, equals(Brightness.light)); - expect(ThemeData(primaryColor: Colors.lime).primaryColorBrightness, equals(Brightness.light)); - expect(ThemeData(primaryColor: Colors.grey).primaryColorBrightness, equals(Brightness.light)); - expect(ThemeData(primaryColor: Colors.teal).primaryColorBrightness, equals(Brightness.dark)); - expect(ThemeData(primaryColor: Colors.indigo).primaryColorBrightness, equals(Brightness.dark)); - }); - test('cursorColor', () { expect(const TextSelectionThemeData(cursorColor: Colors.red).cursorColor, Colors.red); }); @@ -182,7 +169,6 @@ void main() { expect(theme.colorScheme.brightness, Brightness.light); expect(theme.primaryColor, theme.colorScheme.primary); - expect(theme.primaryColorBrightness, Brightness.dark); expect(theme.canvasColor, theme.colorScheme.background); expect(theme.scaffoldBackgroundColor, theme.colorScheme.background); expect(theme.bottomAppBarColor, theme.colorScheme.surface); @@ -232,7 +218,6 @@ void main() { expect(theme.colorScheme.brightness, Brightness.dark); expect(theme.primaryColor, theme.colorScheme.surface); - expect(theme.primaryColorBrightness, Brightness.dark); expect(theme.canvasColor, theme.colorScheme.background); expect(theme.scaffoldBackgroundColor, theme.colorScheme.background); expect(theme.bottomAppBarColor, theme.colorScheme.surface); @@ -279,7 +264,6 @@ void main() { expect(theme.colorScheme.brightness, Brightness.light); expect(theme.primaryColor, theme.colorScheme.primary); - expect(theme.primaryColorBrightness, Brightness.dark); expect(theme.canvasColor, theme.colorScheme.background); expect(theme.scaffoldBackgroundColor, theme.colorScheme.background); expect(theme.bottomAppBarColor, theme.colorScheme.surface); @@ -327,7 +311,6 @@ void main() { expect(theme.colorScheme.brightness, Brightness.light); expect(theme.primaryColor, theme.colorScheme.primary); - expect(theme.primaryColorBrightness, Brightness.dark); expect(theme.canvasColor, theme.colorScheme.background); expect(theme.scaffoldBackgroundColor, theme.colorScheme.background); expect(theme.bottomAppBarColor, theme.colorScheme.surface); @@ -375,7 +358,6 @@ void main() { expect(theme.colorScheme.brightness, Brightness.dark); expect(theme.primaryColor, theme.colorScheme.surface); - expect(theme.primaryColorBrightness, Brightness.dark); expect(theme.canvasColor, theme.colorScheme.background); expect(theme.scaffoldBackgroundColor, theme.colorScheme.background); expect(theme.bottomAppBarColor, theme.colorScheme.surface); @@ -826,7 +808,6 @@ void main() { toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.black)), tooltipTheme: const TooltipThemeData(height: 100), // DEPRECATED (newest deprecations at the bottom) - primaryColorBrightness: Brightness.dark, androidOverscrollIndicator: AndroidOverscrollIndicator.glow, toggleableActiveColor: Colors.black, selectedRowColor: Colors.black, @@ -946,7 +927,6 @@ void main() { tooltipTheme: const TooltipThemeData(height: 100), // DEPRECATED (newest deprecations at the bottom) - primaryColorBrightness: Brightness.light, androidOverscrollIndicator: AndroidOverscrollIndicator.stretch, toggleableActiveColor: Colors.white, selectedRowColor: Colors.white, @@ -1049,7 +1029,6 @@ void main() { tooltipTheme: otherTheme.tooltipTheme, // DEPRECATED (newest deprecations at the bottom) - primaryColorBrightness: otherTheme.primaryColorBrightness, androidOverscrollIndicator: otherTheme.androidOverscrollIndicator, toggleableActiveColor: otherTheme.toggleableActiveColor, selectedRowColor: otherTheme.selectedRowColor, @@ -1153,7 +1132,6 @@ void main() { expect(themeDataCopy.tooltipTheme, equals(otherTheme.tooltipTheme)); // DEPRECATED (newest deprecations at the bottom) - expect(themeDataCopy.primaryColorBrightness, equals(otherTheme.primaryColorBrightness)); expect(themeDataCopy.androidOverscrollIndicator, equals(otherTheme.androidOverscrollIndicator)); expect(themeDataCopy.toggleableActiveColor, equals(otherTheme.toggleableActiveColor)); expect(themeDataCopy.selectedRowColor, equals(otherTheme.selectedRowColor)); @@ -1288,7 +1266,6 @@ void main() { 'toggleButtonsTheme', 'tooltipTheme', // DEPRECATED (newest deprecations at the bottom) - 'primaryColorBrightness', 'androidOverscrollIndicator', 'toggleableActiveColor', 'selectedRowColor',