Unverified Commit df442083 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Remove ThemeData.buttonColor references (#118658)

* Remove ThemeData.buttonColor references

* Fix test

* Remove more buttonColors

* Macro the definition of color scheme

* remove doc reference
parent e8b7f4b2
...@@ -382,13 +382,12 @@ class ButtonThemeData with Diagnosticable { ...@@ -382,13 +382,12 @@ class ButtonThemeData with Diagnosticable {
/// A set of thirteen colors that can be used to derive the button theme's /// A set of thirteen colors that can be used to derive the button theme's
/// colors. /// colors.
/// ///
/// This property was added much later than the theme's set of highly /// This property was added much later than the theme's set of highly specific
/// specific colors, like [ThemeData.buttonColor], [ThemeData.highlightColor], /// colors, like [ThemeData.highlightColor] and [ThemeData.splashColor] etc.
/// [ThemeData.splashColor] etc.
/// ///
/// The colors for new button classes can be defined exclusively in terms /// The colors for new button classes can be defined exclusively in terms of
/// of [colorScheme]. When it's possible, the existing buttons will /// [colorScheme]. When it's possible, the existing buttons will (continue to)
/// (continue to) gradually migrate to it. /// gradually migrate to it.
final ColorScheme? colorScheme; final ColorScheme? colorScheme;
// The minimum size of a button's tap target. // The minimum size of a button's tap target.
......
...@@ -9,9 +9,11 @@ import 'package:material_color_utilities/material_color_utilities.dart'; ...@@ -9,9 +9,11 @@ import 'package:material_color_utilities/material_color_utilities.dart';
import 'colors.dart'; import 'colors.dart';
import 'theme_data.dart'; import 'theme_data.dart';
/// {@template flutter.material.color_scheme.ColorScheme}
/// A set of 30 colors based on the /// A set of 30 colors based on the
/// [Material spec](https://m3.material.io/styles/color/the-color-system/color-roles) /// [Material spec](https://m3.material.io/styles/color/the-color-system/color-roles)
/// that can be used to configure the color properties of most components. /// that can be used to configure the color properties of most components.
/// {@endtemplate}
/// ///
/// The main accent color groups in the scheme are [primary], [secondary], /// The main accent color groups in the scheme are [primary], [secondary],
/// and [tertiary]. /// and [tertiary].
......
...@@ -405,11 +405,6 @@ class ThemeData with Diagnosticable { ...@@ -405,11 +405,6 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v2.3.0-0.1.pre.', 'This feature was deprecated after v2.3.0-0.1.pre.',
) )
IconThemeData? accentIconTheme, IconThemeData? accentIconTheme,
@Deprecated(
'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v2.3.0-0.2.pre.',
)
Color? buttonColor,
@Deprecated( @Deprecated(
'This "fix" is now enabled by default. ' 'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.', 'This feature was deprecated after v2.5.0-1.0.pre.',
...@@ -552,7 +547,7 @@ class ThemeData with Diagnosticable { ...@@ -552,7 +547,7 @@ class ThemeData with Diagnosticable {
// [disabledColor], [highlightColor], and [splashColor]. // [disabledColor], [highlightColor], and [splashColor].
buttonTheme ??= ButtonThemeData( buttonTheme ??= ButtonThemeData(
colorScheme: colorScheme, colorScheme: colorScheme,
buttonColor: buttonColor ?? (isDark ? primarySwatch[600]! : Colors.grey[300]!), buttonColor: isDark ? primarySwatch[600]! : Colors.grey[300]!,
disabledColor: disabledColor, disabledColor: disabledColor,
focusColor: focusColor, focusColor: focusColor,
hoverColor: hoverColor, hoverColor: hoverColor,
...@@ -637,7 +632,6 @@ class ThemeData with Diagnosticable { ...@@ -637,7 +632,6 @@ class ThemeData with Diagnosticable {
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
accentTextTheme = defaultAccentTextTheme.merge(accentTextTheme); accentTextTheme = defaultAccentTextTheme.merge(accentTextTheme);
accentIconTheme ??= accentIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black); accentIconTheme ??= accentIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black);
buttonColor ??= isDark ? primarySwatch[600]! : Colors.grey[300]!;
fixTextFieldOutlineLabel ??= true; fixTextFieldOutlineLabel ??= true;
primaryColorBrightness = estimatedPrimaryColorBrightness; primaryColorBrightness = estimatedPrimaryColorBrightness;
errorColor ??= Colors.red[700]!; errorColor ??= Colors.red[700]!;
...@@ -736,7 +730,6 @@ class ThemeData with Diagnosticable { ...@@ -736,7 +730,6 @@ class ThemeData with Diagnosticable {
accentColorBrightness: accentColorBrightness, accentColorBrightness: accentColorBrightness,
accentTextTheme: accentTextTheme, accentTextTheme: accentTextTheme,
accentIconTheme: accentIconTheme, accentIconTheme: accentIconTheme,
buttonColor: buttonColor,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: fixTextFieldOutlineLabel,
primaryColorBrightness: primaryColorBrightness, primaryColorBrightness: primaryColorBrightness,
androidOverscrollIndicator: androidOverscrollIndicator, androidOverscrollIndicator: androidOverscrollIndicator,
...@@ -874,11 +867,6 @@ class ThemeData with Diagnosticable { ...@@ -874,11 +867,6 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v2.3.0-0.1.pre.', 'This feature was deprecated after v2.3.0-0.1.pre.',
) )
IconThemeData? accentIconTheme, IconThemeData? accentIconTheme,
@Deprecated(
'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v2.3.0-0.2.pre.',
)
Color? buttonColor,
@Deprecated( @Deprecated(
'This "fix" is now enabled by default. ' 'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.', 'This feature was deprecated after v2.5.0-1.0.pre.',
...@@ -928,7 +916,6 @@ class ThemeData with Diagnosticable { ...@@ -928,7 +916,6 @@ class ThemeData with Diagnosticable {
_accentColorBrightness = accentColorBrightness, _accentColorBrightness = accentColorBrightness,
_accentTextTheme = accentTextTheme, _accentTextTheme = accentTextTheme,
_accentIconTheme = accentIconTheme, _accentIconTheme = accentIconTheme,
_buttonColor = buttonColor,
_fixTextFieldOutlineLabel = fixTextFieldOutlineLabel, _fixTextFieldOutlineLabel = fixTextFieldOutlineLabel,
_primaryColorBrightness = primaryColorBrightness, _primaryColorBrightness = primaryColorBrightness,
_toggleableActiveColor = toggleableActiveColor, _toggleableActiveColor = toggleableActiveColor,
...@@ -1022,7 +1009,6 @@ class ThemeData with Diagnosticable { ...@@ -1022,7 +1009,6 @@ class ThemeData with Diagnosticable {
assert(accentColorBrightness != null), assert(accentColorBrightness != null),
assert(accentTextTheme != null), assert(accentTextTheme != null),
assert(accentIconTheme != null), assert(accentIconTheme != null),
assert(buttonColor != null),
assert(fixTextFieldOutlineLabel != null), assert(fixTextFieldOutlineLabel != null),
assert(primaryColorBrightness != null), assert(primaryColorBrightness != null),
assert(errorColor != null), assert(errorColor != null),
...@@ -1405,14 +1391,13 @@ class ThemeData with Diagnosticable { ...@@ -1405,14 +1391,13 @@ class ThemeData with Diagnosticable {
/// The color of [Material] when it is used as a [Card]. /// The color of [Material] when it is used as a [Card].
final Color cardColor; final Color cardColor;
/// A set of twelve colors that can be used to configure the /// {@macro flutter.material.color_scheme.ColorScheme}
/// color properties of most components.
/// ///
/// This property was added much later than the theme's set of highly /// This property was added much later than the theme's set of highly specific
/// specific colors, like [cardColor], [buttonColor], [canvasColor] etc. /// colors, like [cardColor], [canvasColor] etc. New components can be defined
/// New components can be defined exclusively in terms of [colorScheme]. /// exclusively in terms of [colorScheme]. Existing components will gradually
/// Existing components will gradually migrate to it, to the extent /// migrate to it, to the extent that is possible without significant
/// that is possible without significant backwards compatibility breaks. /// backwards compatibility breaks.
final ColorScheme colorScheme; final ColorScheme colorScheme;
/// The background color of [Dialog] elements. /// The background color of [Dialog] elements.
...@@ -1752,14 +1737,6 @@ class ThemeData with Diagnosticable { ...@@ -1752,14 +1737,6 @@ class ThemeData with Diagnosticable {
IconThemeData get accentIconTheme => _accentIconTheme!; IconThemeData get accentIconTheme => _accentIconTheme!;
final IconThemeData? _accentIconTheme; final IconThemeData? _accentIconTheme;
/// The default fill color of the [Material].
@Deprecated(
'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v2.3.0-0.2.pre.',
)
Color get buttonColor => _buttonColor!;
final Color? _buttonColor;
/// An obsolete flag to allow apps to opt-out of a /// An obsolete flag to allow apps to opt-out of a
/// [small fix](https://github.com/flutter/flutter/issues/54028) for the Y /// [small fix](https://github.com/flutter/flutter/issues/54028) for the Y
/// coordinate of the floating label in a [TextField] [OutlineInputBorder]. /// coordinate of the floating label in a [TextField] [OutlineInputBorder].
...@@ -1971,11 +1948,6 @@ class ThemeData with Diagnosticable { ...@@ -1971,11 +1948,6 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v2.3.0-0.1.pre.', 'This feature was deprecated after v2.3.0-0.1.pre.',
) )
IconThemeData? accentIconTheme, IconThemeData? accentIconTheme,
@Deprecated(
'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v2.3.0-0.2.pre.',
)
Color? buttonColor,
@Deprecated( @Deprecated(
'This "fix" is now enabled by default. ' 'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.', 'This feature was deprecated after v2.5.0-1.0.pre.',
...@@ -2112,7 +2084,6 @@ class ThemeData with Diagnosticable { ...@@ -2112,7 +2084,6 @@ class ThemeData with Diagnosticable {
accentColorBrightness: accentColorBrightness ?? _accentColorBrightness, accentColorBrightness: accentColorBrightness ?? _accentColorBrightness,
accentTextTheme: accentTextTheme ?? _accentTextTheme, accentTextTheme: accentTextTheme ?? _accentTextTheme,
accentIconTheme: accentIconTheme ?? _accentIconTheme, accentIconTheme: accentIconTheme ?? _accentIconTheme,
buttonColor: buttonColor ?? _buttonColor,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? _fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? _fixTextFieldOutlineLabel,
primaryColorBrightness: primaryColorBrightness ?? _primaryColorBrightness, primaryColorBrightness: primaryColorBrightness ?? _primaryColorBrightness,
androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator, androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator,
...@@ -2312,7 +2283,6 @@ class ThemeData with Diagnosticable { ...@@ -2312,7 +2283,6 @@ class ThemeData with Diagnosticable {
accentColorBrightness: t < 0.5 ? a.accentColorBrightness : b.accentColorBrightness, accentColorBrightness: t < 0.5 ? a.accentColorBrightness : b.accentColorBrightness,
accentTextTheme: TextTheme.lerp(a.accentTextTheme, b.accentTextTheme, t), accentTextTheme: TextTheme.lerp(a.accentTextTheme, b.accentTextTheme, t),
accentIconTheme: IconThemeData.lerp(a.accentIconTheme, b.accentIconTheme, t), accentIconTheme: IconThemeData.lerp(a.accentIconTheme, b.accentIconTheme, t),
buttonColor: Color.lerp(a.buttonColor, b.buttonColor, t),
fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel,
primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness, primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness,
androidOverscrollIndicator:t < 0.5 ? a.androidOverscrollIndicator : b.androidOverscrollIndicator, androidOverscrollIndicator:t < 0.5 ? a.androidOverscrollIndicator : b.androidOverscrollIndicator,
...@@ -2421,7 +2391,6 @@ class ThemeData with Diagnosticable { ...@@ -2421,7 +2391,6 @@ class ThemeData with Diagnosticable {
other.accentColorBrightness == accentColorBrightness && other.accentColorBrightness == accentColorBrightness &&
other.accentTextTheme == accentTextTheme && other.accentTextTheme == accentTextTheme &&
other.accentIconTheme == accentIconTheme && other.accentIconTheme == accentIconTheme &&
other.buttonColor == buttonColor &&
other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel && other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel &&
other.primaryColorBrightness == primaryColorBrightness && other.primaryColorBrightness == primaryColorBrightness &&
other.androidOverscrollIndicator == androidOverscrollIndicator && other.androidOverscrollIndicator == androidOverscrollIndicator &&
...@@ -2527,7 +2496,6 @@ class ThemeData with Diagnosticable { ...@@ -2527,7 +2496,6 @@ class ThemeData with Diagnosticable {
accentColorBrightness, accentColorBrightness,
accentTextTheme, accentTextTheme,
accentIconTheme, accentIconTheme,
buttonColor,
fixTextFieldOutlineLabel, fixTextFieldOutlineLabel,
primaryColorBrightness, primaryColorBrightness,
androidOverscrollIndicator, androidOverscrollIndicator,
...@@ -2635,7 +2603,6 @@ class ThemeData with Diagnosticable { ...@@ -2635,7 +2603,6 @@ class ThemeData with Diagnosticable {
properties.add(EnumProperty<Brightness>('accentColorBrightness', accentColorBrightness, defaultValue: defaultData.accentColorBrightness, level: DiagnosticLevel.debug)); properties.add(EnumProperty<Brightness>('accentColorBrightness', accentColorBrightness, defaultValue: defaultData.accentColorBrightness, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<TextTheme>('accentTextTheme', accentTextTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<TextTheme>('accentTextTheme', accentTextTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<IconThemeData>('accentIconTheme', accentIconTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<IconThemeData>('accentIconTheme', accentIconTheme, level: DiagnosticLevel.debug));
properties.add(ColorProperty('buttonColor', buttonColor, defaultValue: defaultData.buttonColor, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<bool>('fixTextFieldOutlineLabel', fixTextFieldOutlineLabel, 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<Brightness>('primaryColorBrightness', primaryColorBrightness, defaultValue: defaultData.primaryColorBrightness, level: DiagnosticLevel.debug));
properties.add(EnumProperty<AndroidOverscrollIndicator>('androidOverscrollIndicator', androidOverscrollIndicator, defaultValue: null, level: DiagnosticLevel.debug)); properties.add(EnumProperty<AndroidOverscrollIndicator>('androidOverscrollIndicator', androidOverscrollIndicator, defaultValue: null, level: DiagnosticLevel.debug));
......
...@@ -611,7 +611,7 @@ void main() { ...@@ -611,7 +611,7 @@ void main() {
textStyle: TextStyle(fontSize: 100), textStyle: TextStyle(fontSize: 100),
); );
// Both ThemeDatas include both extensions // Both ThemeData arguments include both extensions.
ThemeData lerped = ThemeData.lerp( ThemeData lerped = ThemeData.lerp(
ThemeData( ThemeData(
extensions: const <ThemeExtension<dynamic>>[ extensions: const <ThemeExtension<dynamic>>[
...@@ -816,7 +816,6 @@ void main() { ...@@ -816,7 +816,6 @@ void main() {
accentColorBrightness: Brightness.dark, accentColorBrightness: Brightness.dark,
accentTextTheme: ThemeData.dark().textTheme, accentTextTheme: ThemeData.dark().textTheme,
accentIconTheme: ThemeData.dark().iconTheme, accentIconTheme: ThemeData.dark().iconTheme,
buttonColor: Colors.black,
fixTextFieldOutlineLabel: false, fixTextFieldOutlineLabel: false,
primaryColorBrightness: Brightness.dark, primaryColorBrightness: Brightness.dark,
androidOverscrollIndicator: AndroidOverscrollIndicator.glow, androidOverscrollIndicator: AndroidOverscrollIndicator.glow,
...@@ -938,7 +937,6 @@ void main() { ...@@ -938,7 +937,6 @@ void main() {
accentColorBrightness: Brightness.light, accentColorBrightness: Brightness.light,
accentIconTheme: ThemeData.light().iconTheme, accentIconTheme: ThemeData.light().iconTheme,
accentTextTheme: ThemeData.light().textTheme, accentTextTheme: ThemeData.light().textTheme,
buttonColor: Colors.white,
fixTextFieldOutlineLabel: true, fixTextFieldOutlineLabel: true,
primaryColorBrightness: Brightness.light, primaryColorBrightness: Brightness.light,
androidOverscrollIndicator: AndroidOverscrollIndicator.stretch, androidOverscrollIndicator: AndroidOverscrollIndicator.stretch,
...@@ -1043,7 +1041,6 @@ void main() { ...@@ -1043,7 +1041,6 @@ void main() {
accentColorBrightness: otherTheme.accentColorBrightness, accentColorBrightness: otherTheme.accentColorBrightness,
accentIconTheme: otherTheme.accentIconTheme, accentIconTheme: otherTheme.accentIconTheme,
accentTextTheme: otherTheme.accentTextTheme, accentTextTheme: otherTheme.accentTextTheme,
buttonColor: otherTheme.buttonColor,
fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel,
primaryColorBrightness: otherTheme.primaryColorBrightness, primaryColorBrightness: otherTheme.primaryColorBrightness,
androidOverscrollIndicator: otherTheme.androidOverscrollIndicator, androidOverscrollIndicator: otherTheme.androidOverscrollIndicator,
...@@ -1149,7 +1146,6 @@ void main() { ...@@ -1149,7 +1146,6 @@ void main() {
expect(themeDataCopy.accentColorBrightness, equals(otherTheme.accentColorBrightness)); expect(themeDataCopy.accentColorBrightness, equals(otherTheme.accentColorBrightness));
expect(themeDataCopy.accentIconTheme, equals(otherTheme.accentIconTheme)); expect(themeDataCopy.accentIconTheme, equals(otherTheme.accentIconTheme));
expect(themeDataCopy.accentTextTheme, equals(otherTheme.accentTextTheme)); expect(themeDataCopy.accentTextTheme, equals(otherTheme.accentTextTheme));
expect(themeDataCopy.buttonColor, equals(otherTheme.buttonColor));
expect(themeDataCopy.fixTextFieldOutlineLabel, equals(otherTheme.fixTextFieldOutlineLabel)); expect(themeDataCopy.fixTextFieldOutlineLabel, equals(otherTheme.fixTextFieldOutlineLabel));
expect(themeDataCopy.primaryColorBrightness, equals(otherTheme.primaryColorBrightness)); expect(themeDataCopy.primaryColorBrightness, equals(otherTheme.primaryColorBrightness));
expect(themeDataCopy.androidOverscrollIndicator, equals(otherTheme.androidOverscrollIndicator)); expect(themeDataCopy.androidOverscrollIndicator, equals(otherTheme.androidOverscrollIndicator));
...@@ -1287,7 +1283,6 @@ void main() { ...@@ -1287,7 +1283,6 @@ void main() {
'accentColorBrightness', 'accentColorBrightness',
'accentTextTheme', 'accentTextTheme',
'accentIconTheme', 'accentIconTheme',
'buttonColor',
'fixTextFieldOutlineLabel', 'fixTextFieldOutlineLabel',
'primaryColorBrightness', 'primaryColorBrightness',
'androidOverscrollIndicator', '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