Skip to content

Commit df44208

Browse files
authored
Remove ThemeData.buttonColor references (#118658)
* Remove ThemeData.buttonColor references * Fix test * Remove more buttonColors * Macro the definition of color scheme * remove doc reference
1 parent e8b7f4b commit df44208

File tree

4 files changed

+15
-52
lines changed

4 files changed

+15
-52
lines changed

packages/flutter/lib/src/material/button_theme.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,12 @@ class ButtonThemeData with Diagnosticable {
382382
/// A set of thirteen colors that can be used to derive the button theme's
383383
/// colors.
384384
///
385-
/// This property was added much later than the theme's set of highly
386-
/// specific colors, like [ThemeData.buttonColor], [ThemeData.highlightColor],
387-
/// [ThemeData.splashColor] etc.
385+
/// This property was added much later than the theme's set of highly specific
386+
/// colors, like [ThemeData.highlightColor] and [ThemeData.splashColor] etc.
388387
///
389-
/// The colors for new button classes can be defined exclusively in terms
390-
/// of [colorScheme]. When it's possible, the existing buttons will
391-
/// (continue to) gradually migrate to it.
388+
/// The colors for new button classes can be defined exclusively in terms of
389+
/// [colorScheme]. When it's possible, the existing buttons will (continue to)
390+
/// gradually migrate to it.
392391
final ColorScheme? colorScheme;
393392

394393
// The minimum size of a button's tap target.

packages/flutter/lib/src/material/color_scheme.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import 'package:material_color_utilities/material_color_utilities.dart';
99
import 'colors.dart';
1010
import 'theme_data.dart';
1111

12+
/// {@template flutter.material.color_scheme.ColorScheme}
1213
/// A set of 30 colors based on the
1314
/// [Material spec](https://m3.material.io/styles/color/the-color-system/color-roles)
1415
/// that can be used to configure the color properties of most components.
16+
/// {@endtemplate}
1517
///
1618
/// The main accent color groups in the scheme are [primary], [secondary],
1719
/// and [tertiary].

packages/flutter/lib/src/material/theme_data.dart

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,6 @@ class ThemeData with Diagnosticable {
405405
'This feature was deprecated after v2.3.0-0.1.pre.',
406406
)
407407
IconThemeData? accentIconTheme,
408-
@Deprecated(
409-
'No longer used by the framework, please remove any reference to it. '
410-
'This feature was deprecated after v2.3.0-0.2.pre.',
411-
)
412-
Color? buttonColor,
413408
@Deprecated(
414409
'This "fix" is now enabled by default. '
415410
'This feature was deprecated after v2.5.0-1.0.pre.',
@@ -552,7 +547,7 @@ class ThemeData with Diagnosticable {
552547
// [disabledColor], [highlightColor], and [splashColor].
553548
buttonTheme ??= ButtonThemeData(
554549
colorScheme: colorScheme,
555-
buttonColor: buttonColor ?? (isDark ? primarySwatch[600]! : Colors.grey[300]!),
550+
buttonColor: isDark ? primarySwatch[600]! : Colors.grey[300]!,
556551
disabledColor: disabledColor,
557552
focusColor: focusColor,
558553
hoverColor: hoverColor,
@@ -637,7 +632,6 @@ class ThemeData with Diagnosticable {
637632
// DEPRECATED (newest deprecations at the bottom)
638633
accentTextTheme = defaultAccentTextTheme.merge(accentTextTheme);
639634
accentIconTheme ??= accentIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black);
640-
buttonColor ??= isDark ? primarySwatch[600]! : Colors.grey[300]!;
641635
fixTextFieldOutlineLabel ??= true;
642636
primaryColorBrightness = estimatedPrimaryColorBrightness;
643637
errorColor ??= Colors.red[700]!;
@@ -736,7 +730,6 @@ class ThemeData with Diagnosticable {
736730
accentColorBrightness: accentColorBrightness,
737731
accentTextTheme: accentTextTheme,
738732
accentIconTheme: accentIconTheme,
739-
buttonColor: buttonColor,
740733
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel,
741734
primaryColorBrightness: primaryColorBrightness,
742735
androidOverscrollIndicator: androidOverscrollIndicator,
@@ -874,11 +867,6 @@ class ThemeData with Diagnosticable {
874867
'This feature was deprecated after v2.3.0-0.1.pre.',
875868
)
876869
IconThemeData? accentIconTheme,
877-
@Deprecated(
878-
'No longer used by the framework, please remove any reference to it. '
879-
'This feature was deprecated after v2.3.0-0.2.pre.',
880-
)
881-
Color? buttonColor,
882870
@Deprecated(
883871
'This "fix" is now enabled by default. '
884872
'This feature was deprecated after v2.5.0-1.0.pre.',
@@ -928,7 +916,6 @@ class ThemeData with Diagnosticable {
928916
_accentColorBrightness = accentColorBrightness,
929917
_accentTextTheme = accentTextTheme,
930918
_accentIconTheme = accentIconTheme,
931-
_buttonColor = buttonColor,
932919
_fixTextFieldOutlineLabel = fixTextFieldOutlineLabel,
933920
_primaryColorBrightness = primaryColorBrightness,
934921
_toggleableActiveColor = toggleableActiveColor,
@@ -1022,7 +1009,6 @@ class ThemeData with Diagnosticable {
10221009
assert(accentColorBrightness != null),
10231010
assert(accentTextTheme != null),
10241011
assert(accentIconTheme != null),
1025-
assert(buttonColor != null),
10261012
assert(fixTextFieldOutlineLabel != null),
10271013
assert(primaryColorBrightness != null),
10281014
assert(errorColor != null),
@@ -1405,14 +1391,13 @@ class ThemeData with Diagnosticable {
14051391
/// The color of [Material] when it is used as a [Card].
14061392
final Color cardColor;
14071393

1408-
/// A set of twelve colors that can be used to configure the
1409-
/// color properties of most components.
1394+
/// {@macro flutter.material.color_scheme.ColorScheme}
14101395
///
1411-
/// This property was added much later than the theme's set of highly
1412-
/// specific colors, like [cardColor], [buttonColor], [canvasColor] etc.
1413-
/// New components can be defined exclusively in terms of [colorScheme].
1414-
/// Existing components will gradually migrate to it, to the extent
1415-
/// that is possible without significant backwards compatibility breaks.
1396+
/// This property was added much later than the theme's set of highly specific
1397+
/// colors, like [cardColor], [canvasColor] etc. New components can be defined
1398+
/// exclusively in terms of [colorScheme]. Existing components will gradually
1399+
/// migrate to it, to the extent that is possible without significant
1400+
/// backwards compatibility breaks.
14161401
final ColorScheme colorScheme;
14171402

14181403
/// The background color of [Dialog] elements.
@@ -1752,14 +1737,6 @@ class ThemeData with Diagnosticable {
17521737
IconThemeData get accentIconTheme => _accentIconTheme!;
17531738
final IconThemeData? _accentIconTheme;
17541739

1755-
/// The default fill color of the [Material].
1756-
@Deprecated(
1757-
'No longer used by the framework, please remove any reference to it. '
1758-
'This feature was deprecated after v2.3.0-0.2.pre.',
1759-
)
1760-
Color get buttonColor => _buttonColor!;
1761-
final Color? _buttonColor;
1762-
17631740
/// An obsolete flag to allow apps to opt-out of a
17641741
/// [small fix](https://github.com/flutter/flutter/issues/54028) for the Y
17651742
/// coordinate of the floating label in a [TextField] [OutlineInputBorder].
@@ -1971,11 +1948,6 @@ class ThemeData with Diagnosticable {
19711948
'This feature was deprecated after v2.3.0-0.1.pre.',
19721949
)
19731950
IconThemeData? accentIconTheme,
1974-
@Deprecated(
1975-
'No longer used by the framework, please remove any reference to it. '
1976-
'This feature was deprecated after v2.3.0-0.2.pre.',
1977-
)
1978-
Color? buttonColor,
19791951
@Deprecated(
19801952
'This "fix" is now enabled by default. '
19811953
'This feature was deprecated after v2.5.0-1.0.pre.',
@@ -2112,7 +2084,6 @@ class ThemeData with Diagnosticable {
21122084
accentColorBrightness: accentColorBrightness ?? _accentColorBrightness,
21132085
accentTextTheme: accentTextTheme ?? _accentTextTheme,
21142086
accentIconTheme: accentIconTheme ?? _accentIconTheme,
2115-
buttonColor: buttonColor ?? _buttonColor,
21162087
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? _fixTextFieldOutlineLabel,
21172088
primaryColorBrightness: primaryColorBrightness ?? _primaryColorBrightness,
21182089
androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator,
@@ -2312,7 +2283,6 @@ class ThemeData with Diagnosticable {
23122283
accentColorBrightness: t < 0.5 ? a.accentColorBrightness : b.accentColorBrightness,
23132284
accentTextTheme: TextTheme.lerp(a.accentTextTheme, b.accentTextTheme, t),
23142285
accentIconTheme: IconThemeData.lerp(a.accentIconTheme, b.accentIconTheme, t),
2315-
buttonColor: Color.lerp(a.buttonColor, b.buttonColor, t),
23162286
fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel,
23172287
primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness,
23182288
androidOverscrollIndicator:t < 0.5 ? a.androidOverscrollIndicator : b.androidOverscrollIndicator,
@@ -2421,7 +2391,6 @@ class ThemeData with Diagnosticable {
24212391
other.accentColorBrightness == accentColorBrightness &&
24222392
other.accentTextTheme == accentTextTheme &&
24232393
other.accentIconTheme == accentIconTheme &&
2424-
other.buttonColor == buttonColor &&
24252394
other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel &&
24262395
other.primaryColorBrightness == primaryColorBrightness &&
24272396
other.androidOverscrollIndicator == androidOverscrollIndicator &&
@@ -2527,7 +2496,6 @@ class ThemeData with Diagnosticable {
25272496
accentColorBrightness,
25282497
accentTextTheme,
25292498
accentIconTheme,
2530-
buttonColor,
25312499
fixTextFieldOutlineLabel,
25322500
primaryColorBrightness,
25332501
androidOverscrollIndicator,
@@ -2635,7 +2603,6 @@ class ThemeData with Diagnosticable {
26352603
properties.add(EnumProperty<Brightness>('accentColorBrightness', accentColorBrightness, defaultValue: defaultData.accentColorBrightness, level: DiagnosticLevel.debug));
26362604
properties.add(DiagnosticsProperty<TextTheme>('accentTextTheme', accentTextTheme, level: DiagnosticLevel.debug));
26372605
properties.add(DiagnosticsProperty<IconThemeData>('accentIconTheme', accentIconTheme, level: DiagnosticLevel.debug));
2638-
properties.add(ColorProperty('buttonColor', buttonColor, defaultValue: defaultData.buttonColor, level: DiagnosticLevel.debug));
26392606
properties.add(DiagnosticsProperty<bool>('fixTextFieldOutlineLabel', fixTextFieldOutlineLabel, level: DiagnosticLevel.debug));
26402607
properties.add(EnumProperty<Brightness>('primaryColorBrightness', primaryColorBrightness, defaultValue: defaultData.primaryColorBrightness, level: DiagnosticLevel.debug));
26412608
properties.add(EnumProperty<AndroidOverscrollIndicator>('androidOverscrollIndicator', androidOverscrollIndicator, defaultValue: null, level: DiagnosticLevel.debug));

packages/flutter/test/material/theme_data_test.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ void main() {
611611
textStyle: TextStyle(fontSize: 100),
612612
);
613613

614-
// Both ThemeDatas include both extensions
614+
// Both ThemeData arguments include both extensions.
615615
ThemeData lerped = ThemeData.lerp(
616616
ThemeData(
617617
extensions: const <ThemeExtension<dynamic>>[
@@ -816,7 +816,6 @@ void main() {
816816
accentColorBrightness: Brightness.dark,
817817
accentTextTheme: ThemeData.dark().textTheme,
818818
accentIconTheme: ThemeData.dark().iconTheme,
819-
buttonColor: Colors.black,
820819
fixTextFieldOutlineLabel: false,
821820
primaryColorBrightness: Brightness.dark,
822821
androidOverscrollIndicator: AndroidOverscrollIndicator.glow,
@@ -938,7 +937,6 @@ void main() {
938937
accentColorBrightness: Brightness.light,
939938
accentIconTheme: ThemeData.light().iconTheme,
940939
accentTextTheme: ThemeData.light().textTheme,
941-
buttonColor: Colors.white,
942940
fixTextFieldOutlineLabel: true,
943941
primaryColorBrightness: Brightness.light,
944942
androidOverscrollIndicator: AndroidOverscrollIndicator.stretch,
@@ -1043,7 +1041,6 @@ void main() {
10431041
accentColorBrightness: otherTheme.accentColorBrightness,
10441042
accentIconTheme: otherTheme.accentIconTheme,
10451043
accentTextTheme: otherTheme.accentTextTheme,
1046-
buttonColor: otherTheme.buttonColor,
10471044
fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel,
10481045
primaryColorBrightness: otherTheme.primaryColorBrightness,
10491046
androidOverscrollIndicator: otherTheme.androidOverscrollIndicator,
@@ -1149,7 +1146,6 @@ void main() {
11491146
expect(themeDataCopy.accentColorBrightness, equals(otherTheme.accentColorBrightness));
11501147
expect(themeDataCopy.accentIconTheme, equals(otherTheme.accentIconTheme));
11511148
expect(themeDataCopy.accentTextTheme, equals(otherTheme.accentTextTheme));
1152-
expect(themeDataCopy.buttonColor, equals(otherTheme.buttonColor));
11531149
expect(themeDataCopy.fixTextFieldOutlineLabel, equals(otherTheme.fixTextFieldOutlineLabel));
11541150
expect(themeDataCopy.primaryColorBrightness, equals(otherTheme.primaryColorBrightness));
11551151
expect(themeDataCopy.androidOverscrollIndicator, equals(otherTheme.androidOverscrollIndicator));
@@ -1287,7 +1283,6 @@ void main() {
12871283
'accentColorBrightness',
12881284
'accentTextTheme',
12891285
'accentIconTheme',
1290-
'buttonColor',
12911286
'fixTextFieldOutlineLabel',
12921287
'primaryColorBrightness',
12931288
'androidOverscrollIndicator',

0 commit comments

Comments
 (0)