Unverified Commit f99f4728 authored by Qun Cheng's avatar Qun Cheng Committed by GitHub

Remove the deprecated accentColor from ThemeData (#120932)

Co-authored-by: 's avatarQun Cheng <quncheng@google.com>
parent 61045052
......@@ -23,7 +23,7 @@ enum ButtonTextTheme {
/// Button text is black or white depending on [ThemeData.brightness].
normal,
/// Button text is [ThemeData.accentColor].
/// Button text is [ColorScheme.secondary].
accent,
/// Button text is based on [ThemeData.primaryColor].
......
......@@ -381,13 +381,6 @@ class ThemeData with Diagnosticable {
ToggleButtonsThemeData? toggleButtonsTheme,
TooltipThemeData? tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
@Deprecated(
'Use colorScheme.secondary instead. '
'For more information, consult the migration guide at '
'https://flutter.dev/docs/release/breaking-changes/theme-data-accent-properties#migration-guide. '
'This feature was deprecated after v2.3.0-0.1.pre.',
)
Color? accentColor,
@Deprecated(
'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.',
......@@ -478,7 +471,6 @@ class ThemeData with Diagnosticable {
primaryColor ??= primarySurfaceColor;
primaryColorBrightness = ThemeData.estimateBrightnessForColor(primarySurfaceColor);
canvasColor ??= colorScheme.background;
accentColor ??= colorScheme.secondary;
scaffoldBackgroundColor ??= colorScheme.background;
bottomAppBarColor ??= colorScheme.surface;
cardColor ??= colorScheme.surface;
......@@ -496,8 +488,7 @@ class ThemeData with Diagnosticable {
primaryColorLight ??= isDark ? Colors.grey[500]! : primarySwatch[100]!;
primaryColorDark ??= isDark ? Colors.black : primarySwatch[700]!;
final bool primaryIsDark = estimatedPrimaryColorBrightness == Brightness.dark;
toggleableActiveColor ??= isDark ? Colors.tealAccent[200]! : (accentColor ?? primarySwatch[600]!);
accentColor ??= isDark ? Colors.tealAccent[200]! : primarySwatch[500]!;
toggleableActiveColor ??= isDark ? Colors.tealAccent[200]! : (colorScheme?.secondary ?? primarySwatch[600]!);
focusColor ??= isDark ? Colors.white.withOpacity(0.12) : Colors.black.withOpacity(0.12);
hoverColor ??= isDark ? Colors.white.withOpacity(0.04) : Colors.black.withOpacity(0.04);
shadowColor ??= Colors.black;
......@@ -510,7 +501,7 @@ class ThemeData with Diagnosticable {
colorScheme ??= ColorScheme.fromSwatch(
primarySwatch: primarySwatch,
primaryColorDark: primaryColorDark,
accentColor: accentColor,
accentColor: isDark ? Colors.tealAccent[200]! : primarySwatch[500]!,
cardColor: cardColor,
backgroundColor: isDark ? Colors.grey[700]! : primarySwatch[200]!,
errorColor: Colors.red[700],
......@@ -521,7 +512,7 @@ class ThemeData with Diagnosticable {
// Spec doesn't specify a dark theme secondaryHeaderColor, this is a guess.
secondaryHeaderColor ??= isDark ? Colors.grey[700]! : primarySwatch[50]!;
dialogBackgroundColor ??= isDark ? Colors.grey[800]! : Colors.white;
indicatorColor ??= accentColor == primaryColor ? Colors.white : accentColor;
indicatorColor ??= colorScheme.secondary == primaryColor ? Colors.white : colorScheme.secondary;
hintColor ??= isDark ? Colors.white60 : Colors.black.withOpacity(0.6);
// The default [buttonTheme] is here because it doesn't use the defaults for
// [disabledColor], [highlightColor], and [splashColor].
......@@ -702,7 +693,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme: toggleButtonsTheme,
tooltipTheme: tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
accentColor: accentColor,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel,
primaryColorBrightness: primaryColorBrightness,
androidOverscrollIndicator: androidOverscrollIndicator,
......@@ -813,13 +803,6 @@ class ThemeData with Diagnosticable {
required this.toggleButtonsTheme,
required this.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
@Deprecated(
'Use colorScheme.secondary instead. '
'For more information, consult the migration guide at '
'https://flutter.dev/docs/release/breaking-changes/theme-data-accent-properties#migration-guide. '
'This feature was deprecated after v2.3.0-0.1.pre.',
)
Color? accentColor,
@Deprecated(
'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.',
......@@ -865,7 +848,6 @@ class ThemeData with Diagnosticable {
}) : // DEPRECATED (newest deprecations at the bottom)
// should not be `required`, use getter pattern to avoid breakages.
_accentColor = accentColor,
_fixTextFieldOutlineLabel = fixTextFieldOutlineLabel,
_primaryColorBrightness = primaryColorBrightness,
_toggleableActiveColor = toggleableActiveColor,
......@@ -875,7 +857,6 @@ class ThemeData with Diagnosticable {
_bottomAppBarColor = bottomAppBarColor,
assert(toggleableActiveColor != null),
// DEPRECATED (newest deprecations at the bottom)
assert(accentColor != null),
assert(fixTextFieldOutlineLabel != null),
assert(primaryColorBrightness != null),
assert(errorColor != null),
......@@ -926,7 +907,6 @@ class ThemeData with Diagnosticable {
primaryColor: primarySurfaceColor,
primaryColorBrightness: ThemeData.estimateBrightnessForColor(primarySurfaceColor),
canvasColor: colorScheme.background,
accentColor: colorScheme.secondary,
scaffoldBackgroundColor: colorScheme.background,
bottomAppBarColor: colorScheme.surface,
cardColor: colorScheme.surface,
......@@ -1534,25 +1514,6 @@ class ThemeData with Diagnosticable {
// DEPRECATED (newest deprecations at the bottom)
/// Obsolete property that was originally used as the foreground
/// color for widgets (knobs, text, overscroll edge effect, etc).
///
/// The material library no longer uses this property. In most cases the
/// [colorScheme]'s [ColorScheme.secondary] property is now used instead.
///
/// Apps should migrate uses of this property to the theme's [colorScheme]
/// [ColorScheme.secondary] color. In cases where a color is needed that
/// contrasts well with the secondary color [ColorScheme.onSecondary]
/// can be used.
@Deprecated(
'Use colorScheme.secondary instead. '
'For more information, consult the migration guide at '
'https://flutter.dev/docs/release/breaking-changes/theme-data-accent-properties#migration-guide. '
'This feature was deprecated after v2.3.0-0.1.pre.',
)
Color get accentColor => _accentColor!;
final Color? _accentColor;
/// An obsolete flag to allow apps to opt-out of a
/// [small fix](https://github.com/flutter/flutter/issues/54028) for the Y
/// coordinate of the floating label in a [TextField] [OutlineInputBorder].
......@@ -1737,13 +1698,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. '
'For more information, consult the migration guide at '
'https://flutter.dev/docs/release/breaking-changes/theme-data-accent-properties#migration-guide. '
'This feature was deprecated after v2.3.0-0.1.pre.',
)
Color? accentColor,
@Deprecated(
'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.',
......@@ -1877,7 +1831,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
tooltipTheme: tooltipTheme ?? this.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
accentColor: accentColor ?? _accentColor,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? _fixTextFieldOutlineLabel,
primaryColorBrightness: primaryColorBrightness ?? _primaryColorBrightness,
androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator,
......@@ -2071,7 +2024,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)
accentColor: Color.lerp(a.accentColor, b.accentColor, t),
fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel,
primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness,
androidOverscrollIndicator:t < 0.5 ? a.androidOverscrollIndicator : b.androidOverscrollIndicator,
......@@ -2177,7 +2129,6 @@ class ThemeData with Diagnosticable {
other.toggleButtonsTheme == toggleButtonsTheme &&
other.tooltipTheme == tooltipTheme &&
// DEPRECATED (newest deprecations at the bottom)
other.accentColor == accentColor &&
other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel &&
other.primaryColorBrightness == primaryColorBrightness &&
other.androidOverscrollIndicator == androidOverscrollIndicator &&
......@@ -2280,7 +2231,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme,
tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
accentColor,
fixTextFieldOutlineLabel,
primaryColorBrightness,
androidOverscrollIndicator,
......@@ -2385,7 +2335,6 @@ class ThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<ToggleButtonsThemeData>('toggleButtonsTheme', toggleButtonsTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<TooltipThemeData>('tooltipTheme', tooltipTheme, level: DiagnosticLevel.debug));
// DEPRECATED (newest deprecations at the bottom)
properties.add(ColorProperty('accentColor', accentColor, defaultValue: defaultData.accentColor, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<bool>('fixTextFieldOutlineLabel', fixTextFieldOutlineLabel, level: DiagnosticLevel.debug));
properties.add(EnumProperty<Brightness>('primaryColorBrightness', primaryColorBrightness, defaultValue: defaultData.primaryColorBrightness, level: DiagnosticLevel.debug));
properties.add(EnumProperty<AndroidOverscrollIndicator>('androidOverscrollIndicator', androidOverscrollIndicator, defaultValue: null, level: DiagnosticLevel.debug));
......
......@@ -186,7 +186,6 @@ void main() {
expect(theme.primaryColor, theme.colorScheme.primary);
expect(theme.primaryColorBrightness, Brightness.dark);
expect(theme.canvasColor, theme.colorScheme.background);
expect(theme.accentColor, theme.colorScheme.secondary);
expect(theme.scaffoldBackgroundColor, theme.colorScheme.background);
expect(theme.bottomAppBarColor, theme.colorScheme.surface);
expect(theme.cardColor, theme.colorScheme.surface);
......@@ -237,7 +236,6 @@ void main() {
expect(theme.primaryColor, theme.colorScheme.surface);
expect(theme.primaryColorBrightness, Brightness.dark);
expect(theme.canvasColor, theme.colorScheme.background);
expect(theme.accentColor, theme.colorScheme.secondary);
expect(theme.scaffoldBackgroundColor, theme.colorScheme.background);
expect(theme.bottomAppBarColor, theme.colorScheme.surface);
expect(theme.cardColor, theme.colorScheme.surface);
......@@ -285,7 +283,6 @@ void main() {
expect(theme.primaryColor, theme.colorScheme.primary);
expect(theme.primaryColorBrightness, Brightness.dark);
expect(theme.canvasColor, theme.colorScheme.background);
expect(theme.accentColor, theme.colorScheme.secondary);
expect(theme.scaffoldBackgroundColor, theme.colorScheme.background);
expect(theme.bottomAppBarColor, theme.colorScheme.surface);
expect(theme.cardColor, theme.colorScheme.surface);
......@@ -334,7 +331,6 @@ void main() {
expect(theme.primaryColor, theme.colorScheme.primary);
expect(theme.primaryColorBrightness, Brightness.dark);
expect(theme.canvasColor, theme.colorScheme.background);
expect(theme.accentColor, theme.colorScheme.secondary);
expect(theme.scaffoldBackgroundColor, theme.colorScheme.background);
expect(theme.bottomAppBarColor, theme.colorScheme.surface);
expect(theme.cardColor, theme.colorScheme.surface);
......@@ -383,7 +379,6 @@ void main() {
expect(theme.primaryColor, theme.colorScheme.surface);
expect(theme.primaryColorBrightness, Brightness.dark);
expect(theme.canvasColor, theme.colorScheme.background);
expect(theme.accentColor, theme.colorScheme.secondary);
expect(theme.scaffoldBackgroundColor, theme.colorScheme.background);
expect(theme.bottomAppBarColor, theme.colorScheme.surface);
expect(theme.cardColor, theme.colorScheme.surface);
......@@ -401,7 +396,6 @@ void main() {
expect(theme.brightness, equals(Brightness.light));
expect(theme.primaryColor, equals(lightColors.primary));
expect(theme.accentColor, equals(lightColors.secondary));
expect(theme.cardColor, equals(lightColors.surface));
expect(theme.backgroundColor, equals(lightColors.background));
expect(theme.canvasColor, equals(lightColors.background));
......@@ -418,7 +412,6 @@ void main() {
expect(theme.brightness, equals(Brightness.dark));
// in dark theme's the color used for main components is surface instead of primary
expect(theme.primaryColor, equals(darkColors.surface));
expect(theme.accentColor, equals(darkColors.secondary));
expect(theme.cardColor, equals(darkColors.surface));
expect(theme.backgroundColor, equals(darkColors.background));
expect(theme.canvasColor, equals(darkColors.background));
......@@ -808,7 +801,6 @@ void main() {
toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.black)),
tooltipTheme: const TooltipThemeData(height: 100),
// DEPRECATED (newest deprecations at the bottom)
accentColor: Colors.black,
fixTextFieldOutlineLabel: false,
primaryColorBrightness: Brightness.dark,
androidOverscrollIndicator: AndroidOverscrollIndicator.glow,
......@@ -927,7 +919,6 @@ void main() {
tooltipTheme: const TooltipThemeData(height: 100),
// DEPRECATED (newest deprecations at the bottom)
accentColor: Colors.white,
fixTextFieldOutlineLabel: true,
primaryColorBrightness: Brightness.light,
androidOverscrollIndicator: AndroidOverscrollIndicator.stretch,
......@@ -1029,7 +1020,6 @@ void main() {
tooltipTheme: otherTheme.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
accentColor: otherTheme.accentColor,
fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel,
primaryColorBrightness: otherTheme.primaryColorBrightness,
androidOverscrollIndicator: otherTheme.androidOverscrollIndicator,
......@@ -1132,7 +1122,6 @@ void main() {
expect(themeDataCopy.tooltipTheme, equals(otherTheme.tooltipTheme));
// DEPRECATED (newest deprecations at the bottom)
expect(themeDataCopy.accentColor, equals(otherTheme.accentColor));
expect(themeDataCopy.fixTextFieldOutlineLabel, equals(otherTheme.fixTextFieldOutlineLabel));
expect(themeDataCopy.primaryColorBrightness, equals(otherTheme.primaryColorBrightness));
expect(themeDataCopy.androidOverscrollIndicator, equals(otherTheme.androidOverscrollIndicator));
......@@ -1171,7 +1160,6 @@ void main() {
expect(theme.brightness, equals(Brightness.dark));
expect(theme.colorScheme.brightness, equals(Brightness.dark));
expect(theme.primaryColor, equals(lightColors.primary));
expect(theme.accentColor, equals(lightColors.secondary));
expect(theme.cardColor, equals(lightColors.surface));
expect(theme.backgroundColor, equals(lightColors.background));
expect(theme.canvasColor, equals(lightColors.background));
......@@ -1267,7 +1255,6 @@ void main() {
'toggleButtonsTheme',
'tooltipTheme',
// DEPRECATED (newest deprecations at the bottom)
'accentColor',
'fixTextFieldOutlineLabel',
'primaryColorBrightness',
'androidOverscrollIndicator',
......
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