Skip to content

Commit 92a46ae

Browse files
authored
ThemeData minor spring cleaning (flutter#148408)
Do a bit of sprucing up of `ThemeData` in anticipation of future work Related: flutter#91772
1 parent 6d424e3 commit 92a46ae

File tree

1 file changed

+17
-34
lines changed

1 file changed

+17
-34
lines changed

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

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,6 @@ abstract class ThemeExtension<T extends ThemeExtension<T>> {
136136
ThemeExtension<T> lerp(covariant ThemeExtension<T>? other, double t);
137137
}
138138

139-
// Deriving these values is black magic. The spec claims that pressed buttons
140-
// have a highlight of 0x66999999, but that's clearly wrong. The videos in the
141-
// spec show that buttons have a composited highlight of #E1E1E1 on a background
142-
// of #FAFAFA. Assuming that the highlight really has an opacity of 0x66, we can
143-
// solve for the actual color of the highlight:
144-
const Color _kLightThemeHighlightColor = Color(0x66BCBCBC);
145-
146-
// The same video shows the splash compositing to #D7D7D7 on a background of
147-
// #E1E1E1. Again, assuming the splash has an opacity of 0x66, we can solve for
148-
// the actual color of the splash:
149-
const Color _kLightThemeSplashColor = Color(0x66C8C8C8);
150-
151-
// Unfortunately, a similar video isn't available for the dark theme, which
152-
// means we assume the values in the spec are actually correct.
153-
const Color _kDarkThemeHighlightColor = Color(0x40CCCCCC);
154-
const Color _kDarkThemeSplashColor = Color(0x40CCCCCC);
155-
156139
/// Configures the tap target and layout size of certain Material widgets.
157140
///
158141
/// Changing the value in [ThemeData.materialTapTargetSize] will affect the
@@ -262,8 +245,8 @@ class ThemeData with Diagnosticable {
262245
/// See also:
263246
///
264247
/// * [ThemeData.from], which creates a ThemeData from a [ColorScheme].
265-
/// * [ThemeData.light], which creates a light blue theme.
266-
/// * [ThemeData.dark], which creates dark theme with a teal secondary [ColorScheme] color.
248+
/// * [ThemeData.light], which creates the default light theme.
249+
/// * [ThemeData.dark], which creates the deafult dark theme.
267250
/// * [ColorScheme.fromSeed], which is used to create a [ColorScheme] from a seed color.
268251
factory ThemeData({
269252
// For the sanity of the reader, make sure these properties are in the same
@@ -285,14 +268,14 @@ class ThemeData with Diagnosticable {
285268
bool? useMaterial3,
286269
VisualDensity? visualDensity,
287270
// COLOR
288-
// [colorScheme] is the preferred way to configure colors. The other color
289-
// properties (as well as primarySwatch) will gradually be phased out, see
290-
// https://github.com/flutter/flutter/issues/91772.
271+
ColorScheme? colorScheme,
291272
Brightness? brightness,
273+
Color? colorSchemeSeed,
274+
// [colorScheme] is the preferred way to configure colors. The [Color] properties
275+
// listed below (as well as primarySwatch) will gradually be phased out, see
276+
// https://github.com/flutter/flutter/issues/91772.
292277
Color? canvasColor,
293278
Color? cardColor,
294-
ColorScheme? colorScheme,
295-
Color? colorSchemeSeed,
296279
Color? dialogBackgroundColor,
297280
Color? disabledColor,
298281
Color? dividerColor,
@@ -365,6 +348,7 @@ class ThemeData with Diagnosticable {
365348
TimePickerThemeData? timePickerTheme,
366349
ToggleButtonsThemeData? toggleButtonsTheme,
367350
TooltipThemeData? tooltipTheme,
351+
// DEPRECATED (newest deprecations at the bottom)
368352
@Deprecated(
369353
'Use OverflowBar instead. '
370354
'This feature was deprecated after v3.21.0-10.0.pre.',
@@ -471,8 +455,8 @@ class ThemeData with Diagnosticable {
471455
materialTapTargetSize: materialTapTargetSize,
472456
);
473457
disabledColor ??= isDark ? Colors.white38 : Colors.black38;
474-
highlightColor ??= isDark ? _kDarkThemeHighlightColor : _kLightThemeHighlightColor;
475-
splashColor ??= isDark ? _kDarkThemeSplashColor : _kLightThemeSplashColor;
458+
highlightColor ??= isDark ? const Color(0x40CCCCCC) : const Color(0x66BCBCBC);
459+
splashColor ??= isDark ? const Color(0x40CCCCCC) : const Color(0x66C8C8C8);
476460

477461
// TYPOGRAPHY & ICONOGRAPHY
478462
typography ??= useMaterial3
@@ -666,12 +650,12 @@ class ThemeData with Diagnosticable {
666650
required this.useMaterial3,
667651
required this.visualDensity,
668652
// COLOR
669-
// [colorScheme] is the preferred way to configure colors. The other color
670-
// properties will gradually be phased out, see
653+
required this.colorScheme,
654+
// [colorScheme] is the preferred way to configure colors. The [Color] properties
655+
// listed below (as well as primarySwatch) will gradually be phased out, see
671656
// https://github.com/flutter/flutter/issues/91772.
672657
required this.canvasColor,
673658
required this.cardColor,
674-
required this.colorScheme,
675659
required this.dialogBackgroundColor,
676660
required this.disabledColor,
677661
required this.dividerColor,
@@ -749,7 +733,6 @@ class ThemeData with Diagnosticable {
749733
}) : // DEPRECATED (newest deprecations at the bottom)
750734
// should not be `required`, use getter pattern to avoid breakages.
751735
_buttonBarTheme = buttonBarTheme,
752-
// DEPRECATED (newest deprecations at the bottom)
753736
assert(buttonBarTheme != null);
754737

755738
/// Create a [ThemeData] based on the colors in the given [colorScheme] and
@@ -1432,13 +1415,13 @@ class ThemeData with Diagnosticable {
14321415
InteractiveInkFeatureFactory? splashFactory,
14331416
VisualDensity? visualDensity,
14341417
// COLOR
1435-
// [colorScheme] is the preferred way to configure colors. The other color
1436-
// properties will gradually be phased out, see
1437-
// https://github.com/flutter/flutter/issues/91772.
1418+
ColorScheme? colorScheme,
14381419
Brightness? brightness,
1420+
// [colorScheme] is the preferred way to configure colors. The [Color] properties
1421+
// listed below (as well as primarySwatch) will gradually be phased out, see
1422+
// https://github.com/flutter/flutter/issues/91772.
14391423
Color? canvasColor,
14401424
Color? cardColor,
1441-
ColorScheme? colorScheme,
14421425
Color? dialogBackgroundColor,
14431426
Color? disabledColor,
14441427
Color? dividerColor,

0 commit comments

Comments
 (0)