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

Remove deprecated `primaryVariant` and `secondaryVariant` from `ColorScheme` (#127124)

This PR is to remove deprecated `primaryVariant` and `secondaryVariant` from framework. These two apis are made obsolete in #93427

Part of https://github.com/flutter/flutter/issues/127042
parent 25d2d4dd
...@@ -112,16 +112,6 @@ class ColorScheme with Diagnosticable { ...@@ -112,16 +112,6 @@ class ColorScheme with Diagnosticable {
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint, Color? surfaceTint,
@Deprecated(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? primaryVariant,
@Deprecated(
'Use secondary or secondaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? secondaryVariant,
}) : _primaryContainer = primaryContainer, }) : _primaryContainer = primaryContainer,
_onPrimaryContainer = onPrimaryContainer, _onPrimaryContainer = onPrimaryContainer,
_secondaryContainer = secondaryContainer, _secondaryContainer = secondaryContainer,
...@@ -141,8 +131,6 @@ class ColorScheme with Diagnosticable { ...@@ -141,8 +131,6 @@ class ColorScheme with Diagnosticable {
_inverseSurface = inverseSurface, _inverseSurface = inverseSurface,
_onInverseSurface = onInverseSurface, _onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary, _inversePrimary = inversePrimary,
_primaryVariant = primaryVariant,
_secondaryVariant = secondaryVariant,
_surfaceTint = surfaceTint; _surfaceTint = surfaceTint;
/// Generate a [ColorScheme] derived from the given `seedColor`. /// Generate a [ColorScheme] derived from the given `seedColor`.
...@@ -277,16 +265,6 @@ class ColorScheme with Diagnosticable { ...@@ -277,16 +265,6 @@ class ColorScheme with Diagnosticable {
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint, Color? surfaceTint,
@Deprecated(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? primaryVariant = const Color(0xff3700b3),
@Deprecated(
'Use secondary or secondaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? secondaryVariant = const Color(0xff018786),
}) : _primaryContainer = primaryContainer, }) : _primaryContainer = primaryContainer,
_onPrimaryContainer = onPrimaryContainer, _onPrimaryContainer = onPrimaryContainer,
_secondaryContainer = secondaryContainer, _secondaryContainer = secondaryContainer,
...@@ -306,8 +284,6 @@ class ColorScheme with Diagnosticable { ...@@ -306,8 +284,6 @@ class ColorScheme with Diagnosticable {
_inverseSurface = inverseSurface, _inverseSurface = inverseSurface,
_onInverseSurface = onInverseSurface, _onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary, _inversePrimary = inversePrimary,
_primaryVariant = primaryVariant,
_secondaryVariant = secondaryVariant,
_surfaceTint = surfaceTint; _surfaceTint = surfaceTint;
/// Create the recommended dark color scheme that matches the /// Create the recommended dark color scheme that matches the
...@@ -344,16 +320,6 @@ class ColorScheme with Diagnosticable { ...@@ -344,16 +320,6 @@ class ColorScheme with Diagnosticable {
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint, Color? surfaceTint,
@Deprecated(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? primaryVariant = const Color(0xff3700B3),
@Deprecated(
'Use secondary or secondaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? secondaryVariant = const Color(0xff03dac6),
}) : _primaryContainer = primaryContainer, }) : _primaryContainer = primaryContainer,
_onPrimaryContainer = onPrimaryContainer, _onPrimaryContainer = onPrimaryContainer,
_secondaryContainer = secondaryContainer, _secondaryContainer = secondaryContainer,
...@@ -373,8 +339,6 @@ class ColorScheme with Diagnosticable { ...@@ -373,8 +339,6 @@ class ColorScheme with Diagnosticable {
_inverseSurface = inverseSurface, _inverseSurface = inverseSurface,
_onInverseSurface = onInverseSurface, _onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary, _inversePrimary = inversePrimary,
_primaryVariant = primaryVariant,
_secondaryVariant = secondaryVariant,
_surfaceTint = surfaceTint; _surfaceTint = surfaceTint;
/// Create a high contrast ColorScheme based on a purple primary color that /// Create a high contrast ColorScheme based on a purple primary color that
...@@ -411,16 +375,6 @@ class ColorScheme with Diagnosticable { ...@@ -411,16 +375,6 @@ class ColorScheme with Diagnosticable {
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint, Color? surfaceTint,
@Deprecated(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? primaryVariant = const Color(0xff000088),
@Deprecated(
'Use secondary or secondaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? secondaryVariant = const Color(0xff018786),
}) : _primaryContainer = primaryContainer, }) : _primaryContainer = primaryContainer,
_onPrimaryContainer = onPrimaryContainer, _onPrimaryContainer = onPrimaryContainer,
_secondaryContainer = secondaryContainer, _secondaryContainer = secondaryContainer,
...@@ -440,8 +394,6 @@ class ColorScheme with Diagnosticable { ...@@ -440,8 +394,6 @@ class ColorScheme with Diagnosticable {
_inverseSurface = inverseSurface, _inverseSurface = inverseSurface,
_onInverseSurface = onInverseSurface, _onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary, _inversePrimary = inversePrimary,
_primaryVariant = primaryVariant,
_secondaryVariant = secondaryVariant,
_surfaceTint = surfaceTint; _surfaceTint = surfaceTint;
/// Create a high contrast ColorScheme based on the dark /// Create a high contrast ColorScheme based on the dark
...@@ -478,16 +430,6 @@ class ColorScheme with Diagnosticable { ...@@ -478,16 +430,6 @@ class ColorScheme with Diagnosticable {
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint, Color? surfaceTint,
@Deprecated(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? primaryVariant = const Color(0xffbe9eff),
@Deprecated(
'Use secondary or secondaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? secondaryVariant = const Color(0xff66fff9),
}) : _primaryContainer = primaryContainer, }) : _primaryContainer = primaryContainer,
_onPrimaryContainer = onPrimaryContainer, _onPrimaryContainer = onPrimaryContainer,
_secondaryContainer = secondaryContainer, _secondaryContainer = secondaryContainer,
...@@ -507,8 +449,6 @@ class ColorScheme with Diagnosticable { ...@@ -507,8 +449,6 @@ class ColorScheme with Diagnosticable {
_inverseSurface = inverseSurface, _inverseSurface = inverseSurface,
_onInverseSurface = onInverseSurface, _onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary, _inversePrimary = inversePrimary,
_primaryVariant = primaryVariant,
_secondaryVariant = secondaryVariant,
_surfaceTint = surfaceTint; _surfaceTint = surfaceTint;
/// Create a color scheme from a [MaterialColor] swatch. /// Create a color scheme from a [MaterialColor] swatch.
...@@ -517,7 +457,6 @@ class ColorScheme with Diagnosticable { ...@@ -517,7 +457,6 @@ class ColorScheme with Diagnosticable {
/// color scheme. /// color scheme.
factory ColorScheme.fromSwatch({ factory ColorScheme.fromSwatch({
MaterialColor primarySwatch = Colors.blue, MaterialColor primarySwatch = Colors.blue,
Color? primaryColorDark,
Color? accentColor, Color? accentColor,
Color? cardColor, Color? cardColor,
Color? backgroundColor, Color? backgroundColor,
...@@ -532,9 +471,7 @@ class ColorScheme with Diagnosticable { ...@@ -532,9 +471,7 @@ class ColorScheme with Diagnosticable {
return ColorScheme( return ColorScheme(
primary: primarySwatch, primary: primarySwatch,
primaryVariant: primaryColorDark ?? (isDark ? Colors.black : primarySwatch[700]!),
secondary: secondary, secondary: secondary,
secondaryVariant: isDark ? Colors.tealAccent[700]! : primarySwatch[700]!,
surface: cardColor ?? (isDark ? Colors.grey[800]! : Colors.white), surface: cardColor ?? (isDark ? Colors.grey[800]! : Colors.white),
background: backgroundColor ?? (isDark ? Colors.grey[700]! : primarySwatch[200]!), background: backgroundColor ?? (isDark ? Colors.grey[700]! : primarySwatch[200]!),
error: errorColor ?? Colors.red[700]!, error: errorColor ?? Colors.red[700]!,
...@@ -726,22 +663,6 @@ class ColorScheme with Diagnosticable { ...@@ -726,22 +663,6 @@ class ColorScheme with Diagnosticable {
/// elevation. /// elevation.
Color get surfaceTint => _surfaceTint ?? primary; Color get surfaceTint => _surfaceTint ?? primary;
final Color? _primaryVariant;
/// A darker version of the primary color.
@Deprecated(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color get primaryVariant => _primaryVariant ?? primary;
final Color? _secondaryVariant;
/// A darker version of the secondary color.
@Deprecated(
'Use secondary or secondaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color get secondaryVariant => _secondaryVariant ?? secondary;
/// Creates a copy of this color scheme with the given fields /// Creates a copy of this color scheme with the given fields
/// replaced by the non-null parameter values. /// replaced by the non-null parameter values.
ColorScheme copyWith({ ColorScheme copyWith({
...@@ -776,16 +697,6 @@ class ColorScheme with Diagnosticable { ...@@ -776,16 +697,6 @@ class ColorScheme with Diagnosticable {
Color? onInverseSurface, Color? onInverseSurface,
Color? inversePrimary, Color? inversePrimary,
Color? surfaceTint, Color? surfaceTint,
@Deprecated(
'Use primary or primaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? primaryVariant,
@Deprecated(
'Use secondary or secondaryContainer instead. '
'This feature was deprecated after v2.6.0-0.0.pre.'
)
Color? secondaryVariant,
}) { }) {
return ColorScheme( return ColorScheme(
brightness: brightness ?? this.brightness, brightness: brightness ?? this.brightness,
...@@ -818,8 +729,6 @@ class ColorScheme with Diagnosticable { ...@@ -818,8 +729,6 @@ class ColorScheme with Diagnosticable {
inverseSurface : inverseSurface ?? this.inverseSurface, inverseSurface : inverseSurface ?? this.inverseSurface,
onInverseSurface : onInverseSurface ?? this.onInverseSurface, onInverseSurface : onInverseSurface ?? this.onInverseSurface,
inversePrimary : inversePrimary ?? this.inversePrimary, inversePrimary : inversePrimary ?? this.inversePrimary,
primaryVariant: primaryVariant ?? this.primaryVariant,
secondaryVariant: secondaryVariant ?? this.secondaryVariant,
surfaceTint: surfaceTint ?? this.surfaceTint, surfaceTint: surfaceTint ?? this.surfaceTint,
); );
} }
...@@ -862,8 +771,6 @@ class ColorScheme with Diagnosticable { ...@@ -862,8 +771,6 @@ class ColorScheme with Diagnosticable {
inverseSurface: Color.lerp(a.inverseSurface, b.inverseSurface, t), inverseSurface: Color.lerp(a.inverseSurface, b.inverseSurface, t),
onInverseSurface: Color.lerp(a.onInverseSurface, b.onInverseSurface, t), onInverseSurface: Color.lerp(a.onInverseSurface, b.onInverseSurface, t),
inversePrimary: Color.lerp(a.inversePrimary, b.inversePrimary, t), inversePrimary: Color.lerp(a.inversePrimary, b.inversePrimary, t),
primaryVariant: Color.lerp(a.primaryVariant, b.primaryVariant, t),
secondaryVariant: Color.lerp(a.secondaryVariant, b.secondaryVariant, t),
surfaceTint: Color.lerp(a.surfaceTint, b.surfaceTint, t), surfaceTint: Color.lerp(a.surfaceTint, b.surfaceTint, t),
); );
} }
...@@ -907,8 +814,6 @@ class ColorScheme with Diagnosticable { ...@@ -907,8 +814,6 @@ class ColorScheme with Diagnosticable {
&& other.inverseSurface == inverseSurface && other.inverseSurface == inverseSurface
&& other.onInverseSurface == onInverseSurface && other.onInverseSurface == onInverseSurface
&& other.inversePrimary == inversePrimary && other.inversePrimary == inversePrimary
&& other.primaryVariant == primaryVariant
&& other.secondaryVariant == secondaryVariant
&& other.surfaceTint == surfaceTint; && other.surfaceTint == surfaceTint;
} }
...@@ -945,8 +850,6 @@ class ColorScheme with Diagnosticable { ...@@ -945,8 +850,6 @@ class ColorScheme with Diagnosticable {
inverseSurface, inverseSurface,
onInverseSurface, onInverseSurface,
inversePrimary, inversePrimary,
primaryVariant,
secondaryVariant,
surfaceTint, surfaceTint,
), ),
); );
...@@ -985,8 +888,6 @@ class ColorScheme with Diagnosticable { ...@@ -985,8 +888,6 @@ class ColorScheme with Diagnosticable {
properties.add(ColorProperty('inverseSurface', inverseSurface, defaultValue: defaultScheme.inverseSurface)); properties.add(ColorProperty('inverseSurface', inverseSurface, defaultValue: defaultScheme.inverseSurface));
properties.add(ColorProperty('onInverseSurface', onInverseSurface, defaultValue: defaultScheme.onInverseSurface)); properties.add(ColorProperty('onInverseSurface', onInverseSurface, defaultValue: defaultScheme.onInverseSurface));
properties.add(ColorProperty('inversePrimary', inversePrimary, defaultValue: defaultScheme.inversePrimary)); properties.add(ColorProperty('inversePrimary', inversePrimary, defaultValue: defaultScheme.inversePrimary));
properties.add(ColorProperty('primaryVariant', primaryVariant, defaultValue: defaultScheme.primaryVariant));
properties.add(ColorProperty('secondaryVariant', secondaryVariant, defaultValue: defaultScheme.secondaryVariant));
properties.add(ColorProperty('surfaceTint', surfaceTint, defaultValue: defaultScheme.surfaceTint)); properties.add(ColorProperty('surfaceTint', surfaceTint, defaultValue: defaultScheme.surfaceTint));
} }
......
...@@ -561,9 +561,7 @@ class _SnackBarState extends State<SnackBar> { ...@@ -561,9 +561,7 @@ class _SnackBarState extends State<SnackBar> {
: theme.copyWith( : theme.copyWith(
colorScheme: ColorScheme( colorScheme: ColorScheme(
primary: colorScheme.onPrimary, primary: colorScheme.onPrimary,
primaryVariant: colorScheme.onPrimary,
secondary: buttonColor, secondary: buttonColor,
secondaryVariant: colorScheme.onSecondary,
surface: colorScheme.onSurface, surface: colorScheme.onSurface,
background: defaults.backgroundColor!, background: defaults.backgroundColor!,
error: colorScheme.onError, error: colorScheme.onError,
......
...@@ -500,7 +500,6 @@ class ThemeData with Diagnosticable { ...@@ -500,7 +500,6 @@ class ThemeData with Diagnosticable {
// with the existing default ThemeData color values. // with the existing default ThemeData color values.
colorScheme ??= ColorScheme.fromSwatch( colorScheme ??= ColorScheme.fromSwatch(
primarySwatch: primarySwatch, primarySwatch: primarySwatch,
primaryColorDark: primaryColorDark,
accentColor: isDark ? Colors.tealAccent[200]! : primarySwatch[500]!, accentColor: isDark ? Colors.tealAccent[200]! : primarySwatch[500]!,
cardColor: cardColor, cardColor: cardColor,
backgroundColor: isDark ? Colors.grey[700]! : primarySwatch[200]!, backgroundColor: isDark ? Colors.grey[700]! : primarySwatch[200]!,
......
...@@ -52,9 +52,6 @@ void main() { ...@@ -52,9 +52,6 @@ void main() {
expect(scheme.onInverseSurface, scheme.surface); expect(scheme.onInverseSurface, scheme.surface);
expect(scheme.inversePrimary, scheme.onPrimary); expect(scheme.inversePrimary, scheme.onPrimary);
expect(scheme.surfaceTint, scheme.primary); expect(scheme.surfaceTint, scheme.primary);
expect(scheme.primaryVariant, const Color(0xff3700b3));
expect(scheme.secondaryVariant, const Color(0xff018786));
}); });
test('dark scheme matches the spec', () { test('dark scheme matches the spec', () {
...@@ -94,9 +91,6 @@ void main() { ...@@ -94,9 +91,6 @@ void main() {
expect(scheme.onInverseSurface, scheme.surface); expect(scheme.onInverseSurface, scheme.surface);
expect(scheme.inversePrimary, scheme.onPrimary); expect(scheme.inversePrimary, scheme.onPrimary);
expect(scheme.surfaceTint, scheme.primary); expect(scheme.surfaceTint, scheme.primary);
expect(scheme.primaryVariant, const Color(0xff3700b3));
expect(scheme.secondaryVariant, const Color(0xff03dac6));
}); });
test('high contrast light scheme matches the spec', () { test('high contrast light scheme matches the spec', () {
...@@ -136,9 +130,6 @@ void main() { ...@@ -136,9 +130,6 @@ void main() {
expect(scheme.onInverseSurface, scheme.surface); expect(scheme.onInverseSurface, scheme.surface);
expect(scheme.inversePrimary, scheme.onPrimary); expect(scheme.inversePrimary, scheme.onPrimary);
expect(scheme.surfaceTint, scheme.primary); expect(scheme.surfaceTint, scheme.primary);
expect(scheme.primaryVariant, const Color(0xff000088));
expect(scheme.secondaryVariant, const Color(0xff018786));
}); });
test('high contrast dark scheme matches the spec', () { test('high contrast dark scheme matches the spec', () {
...@@ -178,9 +169,6 @@ void main() { ...@@ -178,9 +169,6 @@ void main() {
expect(scheme.onInverseSurface, scheme.surface); expect(scheme.onInverseSurface, scheme.surface);
expect(scheme.inversePrimary, scheme.onPrimary); expect(scheme.inversePrimary, scheme.onPrimary);
expect(scheme.surfaceTint, scheme.primary); expect(scheme.surfaceTint, scheme.primary);
expect(scheme.primaryVariant, const Color(0xffbe9eff));
expect(scheme.secondaryVariant, const Color(0xff66fff9));
}); });
test('can generate a light scheme from a seed color', () { test('can generate a light scheme from a seed color', () {
...@@ -251,9 +239,6 @@ void main() { ...@@ -251,9 +239,6 @@ void main() {
onInverseSurface: const Color(0x0000001A), onInverseSurface: const Color(0x0000001A),
inversePrimary: const Color(0x0000001B), inversePrimary: const Color(0x0000001B),
surfaceTint: const Color(0x0000001C), surfaceTint: const Color(0x0000001C),
primaryVariant: const Color(0x0000001D),
secondaryVariant: const Color(0x0000001F),
); );
expect(scheme.brightness, Brightness.dark); expect(scheme.brightness, Brightness.dark);
...@@ -287,9 +272,6 @@ void main() { ...@@ -287,9 +272,6 @@ void main() {
expect(scheme.onInverseSurface, const Color(0x0000001A)); expect(scheme.onInverseSurface, const Color(0x0000001A));
expect(scheme.inversePrimary, const Color(0x0000001B)); expect(scheme.inversePrimary, const Color(0x0000001B));
expect(scheme.surfaceTint, const Color(0x0000001C)); expect(scheme.surfaceTint, const Color(0x0000001C));
expect(scheme.primaryVariant, const Color(0x0000001D));
expect(scheme.secondaryVariant, const Color(0x0000001F));
}); });
test('can generate a dark scheme from a seed color', () { test('can generate a dark scheme from a seed color', () {
...@@ -406,9 +388,6 @@ void main() { ...@@ -406,9 +388,6 @@ void main() {
expect(scheme.onInverseSurface, const Color(0xfff3eff4)); expect(scheme.onInverseSurface, const Color(0xfff3eff4));
expect(scheme.inversePrimary, const Color(0xffc0c1ff)); expect(scheme.inversePrimary, const Color(0xffc0c1ff));
expect(scheme.surfaceTint, const Color(0xff4040f3)); expect(scheme.surfaceTint, const Color(0xff4040f3));
expect(scheme.primaryVariant, const Color(0xff4040f3));
expect(scheme.secondaryVariant, const Color(0xff5d5c72));
}, skip: isBrowser, // [intended] uses dart:typed_data. }, skip: isBrowser, // [intended] uses dart:typed_data.
); );
...@@ -446,8 +425,6 @@ void main() { ...@@ -446,8 +425,6 @@ void main() {
expect(scheme.inverseSurface, const Color(0xffe5e1e6)); expect(scheme.inverseSurface, const Color(0xffe5e1e6));
expect(scheme.onInverseSurface, const Color(0xff313034)); expect(scheme.onInverseSurface, const Color(0xff313034));
expect(scheme.inversePrimary, const Color(0xff4040f3)); expect(scheme.inversePrimary, const Color(0xff4040f3));
expect(scheme.primaryVariant, const Color(0xffc0c1ff));
expect(scheme.secondaryVariant, const Color(0xffc6c4dd));
expect(scheme.surfaceTint, const Color(0xffc0c1ff)); expect(scheme.surfaceTint, const Color(0xffc0c1ff));
}, skip: isBrowser, // [intended] uses dart:isolate and io. }, skip: isBrowser, // [intended] uses dart:isolate and io.
); );
......
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