From 08496712b0a0076288c1ce26b966d83ce0c15efd Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Tue, 17 May 2022 20:57:08 -0700 Subject: [PATCH] Reorder Theme fields and arguments to be consistently alphabetical within sections. (#104011) --- .../flutter/lib/src/material/theme_data.dart | 836 +++++++++--------- .../test/material/theme_data_test.dart | 136 +-- 2 files changed, 508 insertions(+), 464 deletions(-) diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index b9694c113a..7ef7b2b89a 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -267,6 +267,11 @@ class ThemeData with Diagnosticable { /// * [ThemeData.dark], which creates dark theme with a teal secondary [ColorScheme] color. /// * [ColorScheme.fromSeed], which is used to create a [ColorScheme] from a seed color. factory ThemeData({ + // For the sanity of the reader, make sure these properties are in the same + // order in every place that they are separated by section comments (e.g. + // GENERAL CONFIGURATION). Each section except for deprecations should be + // alphabetical by symbol name. + // GENERAL CONFIGURATION bool? applyElevationOverlayColor, NoDefaultCupertinoThemeData? cupertinoOverrideTheme, @@ -277,46 +282,46 @@ class ThemeData with Diagnosticable { TargetPlatform? platform, ScrollbarThemeData? scrollbarTheme, InteractiveInkFeatureFactory? splashFactory, - VisualDensity? visualDensity, bool? useMaterial3, + VisualDensity? visualDensity, // COLOR // [colorScheme] is the preferred way to configure colors. The other color // properties (as well as primaryColorBrightness, and primarySwatch) // will gradually be phased out, see https://github.com/flutter/flutter/issues/91772. + Color? backgroundColor, + Color? bottomAppBarColor, + Brightness? brightness, + Color? canvasColor, + Color? cardColor, ColorScheme? colorScheme, Color? colorSchemeSeed, - Brightness? brightness, - MaterialColor? primarySwatch, - Color? primaryColor, - Color? primaryColorLight, - Color? primaryColorDark, - Color? focusColor, - Color? hoverColor, - Color? shadowColor, - Color? canvasColor, - Color? scaffoldBackgroundColor, - Color? bottomAppBarColor, - Color? cardColor, - Color? dividerColor, - Color? highlightColor, - Color? splashColor, - Color? selectedRowColor, - Color? unselectedWidgetColor, - Color? disabledColor, - Color? secondaryHeaderColor, - Color? backgroundColor, Color? dialogBackgroundColor, - Color? indicatorColor, - Color? hintColor, + Color? disabledColor, + Color? dividerColor, Color? errorColor, + Color? focusColor, + Color? highlightColor, + Color? hintColor, + Color? hoverColor, + Color? indicatorColor, + Color? primaryColor, + Color? primaryColorDark, + Color? primaryColorLight, + MaterialColor? primarySwatch, + Color? scaffoldBackgroundColor, + Color? secondaryHeaderColor, + Color? selectedRowColor, + Color? shadowColor, + Color? splashColor, Color? toggleableActiveColor, + Color? unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY String? fontFamily, - Typography? typography, - TextTheme? textTheme, - TextTheme? primaryTextTheme, IconThemeData? iconTheme, IconThemeData? primaryIconTheme, + TextTheme? primaryTextTheme, + TextTheme? textTheme, + Typography? typography, // COMPONENT THEMES AppBarTheme? appBarTheme, MaterialBannerThemeData? bannerTheme, @@ -333,6 +338,7 @@ class ThemeData with Diagnosticable { DividerThemeData? dividerTheme, DrawerThemeData? drawerTheme, ElevatedButtonThemeData? elevatedButtonTheme, + ExpansionTileThemeData? expansionTileTheme, FloatingActionButtonThemeData? floatingActionButtonTheme, ListTileThemeData? listTileTheme, NavigationBarThemeData? navigationBarTheme, @@ -350,7 +356,6 @@ class ThemeData with Diagnosticable { TimePickerThemeData? timePickerTheme, ToggleButtonsThemeData? toggleButtonsTheme, TooltipThemeData? tooltipTheme, - ExpansionTileThemeData? expansionTileTheme, // DEPRECATED (newest deprecations at the bottom) @Deprecated( 'Use colorScheme.secondary instead. ' @@ -569,6 +574,11 @@ class ThemeData with Diagnosticable { primaryColorBrightness = estimatedPrimaryColorBrightness; return ThemeData.raw( + // For the sanity of the reader, make sure these properties are in the same + // order in every place that they are separated by section comments (e.g. + // GENERAL CONFIGURATION). Each section except for deprecations should be + // alphabetical by symbol name. + // GENERAL CONFIGURATION applyElevationOverlayColor: applyElevationOverlayColor, cupertinoOverrideTheme: cupertinoOverrideTheme, @@ -579,38 +589,38 @@ class ThemeData with Diagnosticable { platform: platform, scrollbarTheme: scrollbarTheme, splashFactory: splashFactory, - visualDensity: visualDensity, useMaterial3: useMaterial3, + visualDensity: visualDensity, // COLOR - colorScheme: colorScheme, - primaryColor: primaryColor, - primaryColorLight: primaryColorLight, - primaryColorDark: primaryColorDark, - focusColor: focusColor, - hoverColor: hoverColor, - shadowColor: shadowColor, - canvasColor: canvasColor, - scaffoldBackgroundColor: scaffoldBackgroundColor, - bottomAppBarColor: bottomAppBarColor, - cardColor: cardColor, - dividerColor: dividerColor, - highlightColor: highlightColor, - splashColor: splashColor, - selectedRowColor: selectedRowColor, - unselectedWidgetColor: unselectedWidgetColor, - disabledColor: disabledColor, - secondaryHeaderColor: secondaryHeaderColor, backgroundColor: backgroundColor, + bottomAppBarColor: bottomAppBarColor, + canvasColor: canvasColor, + cardColor: cardColor, + colorScheme: colorScheme, dialogBackgroundColor: dialogBackgroundColor, - indicatorColor: indicatorColor, - hintColor: hintColor, + disabledColor: disabledColor, + dividerColor: dividerColor, errorColor: errorColor, + focusColor: focusColor, + highlightColor: highlightColor, + hintColor: hintColor, + hoverColor: hoverColor, + indicatorColor: indicatorColor, + primaryColor: primaryColor, + primaryColorDark: primaryColorDark, + primaryColorLight: primaryColorLight, + scaffoldBackgroundColor: scaffoldBackgroundColor, + secondaryHeaderColor: secondaryHeaderColor, + selectedRowColor: selectedRowColor, + shadowColor: shadowColor, + splashColor: splashColor, toggleableActiveColor: toggleableActiveColor, + unselectedWidgetColor: unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY - typography: typography, - textTheme: textTheme, - primaryTextTheme: primaryTextTheme, iconTheme: iconTheme, + primaryTextTheme: primaryTextTheme, + textTheme: textTheme, + typography: typography, primaryIconTheme: primaryIconTheme, // COMPONENT THEMES appBarTheme: appBarTheme, @@ -628,6 +638,7 @@ class ThemeData with Diagnosticable { dividerTheme: dividerTheme, drawerTheme: drawerTheme, elevatedButtonTheme: elevatedButtonTheme, + expansionTileTheme: expansionTileTheme, floatingActionButtonTheme: floatingActionButtonTheme, listTileTheme: listTileTheme, navigationBarTheme: navigationBarTheme, @@ -645,7 +656,6 @@ class ThemeData with Diagnosticable { timePickerTheme: timePickerTheme, toggleButtonsTheme: toggleButtonsTheme, tooltipTheme: tooltipTheme, - expansionTileTheme: expansionTileTheme, // DEPRECATED (newest deprecations at the bottom) accentColor: accentColor, accentColorBrightness: accentColorBrightness, @@ -666,9 +676,11 @@ class ThemeData with Diagnosticable { /// create intermediate themes based on two themes created with the /// [ThemeData] constructor. const ThemeData.raw({ - // Warning: make sure these properties are in the exact same order as in - // operator == and in the Object.hash method and in the order of fields - // in this class, and in the lerp() method. + // For the sanity of the reader, make sure these properties are in the same + // order in every place that they are separated by section comments (e.g. + // GENERAL CONFIGURATION). Each section except for deprecations should be + // alphabetical by symbol name. + // GENERAL CONFIGURATION required this.applyElevationOverlayColor, required this.cupertinoOverrideTheme, @@ -679,42 +691,42 @@ class ThemeData with Diagnosticable { required this.platform, required this.scrollbarTheme, required this.splashFactory, - required this.visualDensity, required this.useMaterial3, + required this.visualDensity, // COLOR // [colorScheme] is the preferred way to configure colors. The other color // properties will gradually be phased out, see // https://github.com/flutter/flutter/issues/91772. - required this.colorScheme, - required this.primaryColor, - required this.primaryColorLight, - required this.primaryColorDark, - required this.focusColor, - required this.hoverColor, - required this.shadowColor, - required this.canvasColor, - required this.scaffoldBackgroundColor, - required this.bottomAppBarColor, - required this.cardColor, - required this.dividerColor, - required this.highlightColor, - required this.splashColor, - required this.selectedRowColor, - required this.unselectedWidgetColor, - required this.disabledColor, - required this.secondaryHeaderColor, required this.backgroundColor, + required this.bottomAppBarColor, + required this.canvasColor, + required this.cardColor, + required this.colorScheme, required this.dialogBackgroundColor, - required this.indicatorColor, - required this.hintColor, + required this.disabledColor, + required this.dividerColor, required this.errorColor, + required this.focusColor, + required this.highlightColor, + required this.hintColor, + required this.hoverColor, + required this.indicatorColor, + required this.primaryColor, + required this.primaryColorDark, + required this.primaryColorLight, + required this.scaffoldBackgroundColor, + required this.secondaryHeaderColor, + required this.selectedRowColor, + required this.shadowColor, + required this.splashColor, required this.toggleableActiveColor, + required this.unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY - required this.typography, - required this.textTheme, - required this.primaryTextTheme, required this.iconTheme, required this.primaryIconTheme, + required this.primaryTextTheme, + required this.textTheme, + required this.typography, // COMPONENT THEMES required this.appBarTheme, required this.bannerTheme, @@ -731,6 +743,7 @@ class ThemeData with Diagnosticable { required this.dividerTheme, required this.drawerTheme, required this.elevatedButtonTheme, + required this.expansionTileTheme, required this.floatingActionButtonTheme, required this.listTileTheme, required this.navigationBarTheme, @@ -748,7 +761,6 @@ class ThemeData with Diagnosticable { required this.timePickerTheme, required this.toggleButtonsTheme, required this.tooltipTheme, - required this.expansionTileTheme, // DEPRECATED (newest deprecations at the bottom) @Deprecated( 'Use colorScheme.secondary instead. ' @@ -816,39 +828,39 @@ class ThemeData with Diagnosticable { assert(platform != null), assert(scrollbarTheme != null), assert(splashFactory != null), - assert(visualDensity != null), assert(useMaterial3 != null), + assert(visualDensity != null), // COLOR - assert(colorScheme != null), - assert(primaryColor != null), - assert(primaryColorLight != null), - assert(primaryColorDark != null), - assert(focusColor != null), - assert(hoverColor != null), - assert(shadowColor != null), - assert(canvasColor != null), - assert(scaffoldBackgroundColor != null), - assert(bottomAppBarColor != null), - assert(cardColor != null), - assert(dividerColor != null), - assert(highlightColor != null), - assert(splashColor != null), - assert(selectedRowColor != null), - assert(unselectedWidgetColor != null), - assert(disabledColor != null), - assert(secondaryHeaderColor != null), assert(backgroundColor != null), + assert(bottomAppBarColor != null), + assert(canvasColor != null), + assert(cardColor != null), + assert(colorScheme != null), assert(dialogBackgroundColor != null), - assert(indicatorColor != null), - assert(hintColor != null), + assert(disabledColor != null), + assert(dividerColor != null), assert(errorColor != null), + assert(focusColor != null), + assert(highlightColor != null), + assert(hintColor != null), + assert(hoverColor != null), + assert(indicatorColor != null), + assert(primaryColor != null), + assert(primaryColorDark != null), + assert(primaryColorLight != null), + assert(scaffoldBackgroundColor != null), + assert(secondaryHeaderColor != null), + assert(selectedRowColor != null), + assert(shadowColor != null), + assert(splashColor != null), assert(toggleableActiveColor != null), + assert(unselectedWidgetColor != null), // TYPOGRAPHY & ICONOGRAPHY - assert(typography != null), - assert(textTheme != null), - assert(primaryTextTheme != null), assert(iconTheme != null), assert(primaryIconTheme != null), + assert(primaryTextTheme != null), + assert(textTheme != null), + assert(typography != null), // COMPONENT THEMES assert(appBarTheme != null), assert(bannerTheme != null), @@ -865,6 +877,7 @@ class ThemeData with Diagnosticable { assert(dividerTheme != null), assert(drawerTheme != null), assert(elevatedButtonTheme != null), + assert(expansionTileTheme != null), assert(floatingActionButtonTheme != null), assert(listTileTheme != null), assert(navigationBarTheme != null), @@ -881,8 +894,7 @@ class ThemeData with Diagnosticable { assert(textSelectionTheme != null), assert(timePickerTheme != null), assert(toggleButtonsTheme != null), - assert(tooltipTheme != null), - assert(expansionTileTheme != null); + assert(tooltipTheme != null); /// Create a [ThemeData] based on the colors in the given [colorScheme] and /// text styles of the optional [textTheme]. @@ -975,33 +987,13 @@ class ThemeData with Diagnosticable { /// theme is constructed with [Brightness.dark]. Brightness get brightness => colorScheme.brightness; - // Warning: make sure these properties are in the exact same order as in - // Object.hash() and in the raw constructor and in the order of fields in - // the class and in the lerp() method. + // For the sanity of the reader, make sure these properties are in the same + // order in every place that they are separated by section comments (e.g. + // GENERAL CONFIGURATION). Each section except for deprecations should be + // alphabetical by symbol name. // GENERAL CONFIGURATION - /// Specifies which overscroll indicator to use on [TargetPlatform.android]. - /// - /// When null, the default value of - /// [MaterialScrollBehavior.androidOverscrollIndicator] is - /// [AndroidOverscrollIndicator.glow]. - /// - /// This property is deprecated. Use the [useMaterial3] flag instead, or - /// override [ScrollBehavior.buildOverscrollIndicator]. - /// - /// See also: - /// - /// * [StretchingOverscrollIndicator], a Material Design edge effect - /// that transforms the contents of a scrollable when overscrolled. - /// * [GlowingOverscrollIndicator], an edge effect that paints a glow - /// over the contents of a scrollable when overscrolled. - @Deprecated( - 'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. ' - 'This feature was deprecated after v2.13.0-0.0.pre.' - ) - final AndroidOverscrollIndicator? androidOverscrollIndicator; - /// Apply a semi-transparent overlay color on Material surfaces to indicate /// elevation for dark themes. /// @@ -1139,35 +1131,6 @@ class ThemeData with Diagnosticable { /// splash with sparkle effects. final InteractiveInkFeatureFactory splashFactory; - /// The density value for specifying the compactness of various UI components. - /// - /// {@template flutter.material.themedata.visualDensity} - /// Density, in the context of a UI, is the vertical and horizontal - /// "compactness" of the elements in the UI. It is unitless, since it means - /// different things to different UI elements. For buttons, it affects the - /// spacing around the centered label of the button. For lists, it affects the - /// distance between baselines of entries in the list. - /// - /// Typically, density values are integral, but any value in range may be - /// used. The range includes values from [VisualDensity.minimumDensity] (which - /// is -4), to [VisualDensity.maximumDensity] (which is 4), inclusive, where - /// negative values indicate a denser, more compact, UI, and positive values - /// indicate a less dense, more expanded, UI. If a component doesn't support - /// the value given, it will clamp to the nearest supported value. - /// - /// The default for visual densities is zero for both vertical and horizontal - /// densities, which corresponds to the default visual density of components - /// in the Material Design specification. - /// - /// As a rule of thumb, a change of 1 or -1 in density corresponds to 4 - /// logical pixels. However, this is not a strict relationship since - /// components interpret the density values appropriately for their needs. - /// - /// A larger value translates to a spacing increase (less dense), and a - /// smaller value translates to a spacing decrease (more dense). - /// {@endtemplate} - final VisualDensity visualDensity; - /// A temporary flag used to opt-in to Material 3 features. /// /// If true, then components that have been migrated to Material 3 will @@ -1219,8 +1182,52 @@ class ThemeData with Diagnosticable { /// * [Material Design 3](https://m3.material.io/). final bool useMaterial3; + /// The density value for specifying the compactness of various UI components. + /// + /// {@template flutter.material.themedata.visualDensity} + /// Density, in the context of a UI, is the vertical and horizontal + /// "compactness" of the elements in the UI. It is unitless, since it means + /// different things to different UI elements. For buttons, it affects the + /// spacing around the centered label of the button. For lists, it affects the + /// distance between baselines of entries in the list. + /// + /// Typically, density values are integral, but any value in range may be + /// used. The range includes values from [VisualDensity.minimumDensity] (which + /// is -4), to [VisualDensity.maximumDensity] (which is 4), inclusive, where + /// negative values indicate a denser, more compact, UI, and positive values + /// indicate a less dense, more expanded, UI. If a component doesn't support + /// the value given, it will clamp to the nearest supported value. + /// + /// The default for visual densities is zero for both vertical and horizontal + /// densities, which corresponds to the default visual density of components + /// in the Material Design specification. + /// + /// As a rule of thumb, a change of 1 or -1 in density corresponds to 4 + /// logical pixels. However, this is not a strict relationship since + /// components interpret the density values appropriately for their needs. + /// + /// A larger value translates to a spacing increase (less dense), and a + /// smaller value translates to a spacing decrease (more dense). + /// {@endtemplate} + final VisualDensity visualDensity; + // COLOR + /// A color that contrasts with the [primaryColor], e.g. used as the + /// remaining part of a progress bar. + final Color backgroundColor; + + /// The default color of the [BottomAppBar]. + /// + /// This can be overridden by specifying [BottomAppBar.color]. + final Color bottomAppBarColor; + + /// The default color of [MaterialType.canvas] [Material]. + final Color canvasColor; + + /// The color of [Material] when it is used as a [Card]. + final Color cardColor; + /// A set of twelve colors that can be used to configure the /// color properties of most components. /// @@ -1231,6 +1238,42 @@ class ThemeData with Diagnosticable { /// that is possible without significant backwards compatibility breaks. final ColorScheme colorScheme; + /// The background color of [Dialog] elements. + final Color dialogBackgroundColor; + + /// The color used for widgets that are inoperative, regardless of + /// their state. For example, a disabled checkbox (which may be + /// checked or unchecked). + final Color disabledColor; + + /// The color of [Divider]s and [PopupMenuDivider]s, also used + /// between [ListTile]s, between rows in [DataTable]s, and so forth. + /// + /// To create an appropriate [BorderSide] that uses this color, consider + /// [Divider.createBorderSide]. + final Color dividerColor; + + /// The color to use for input validation errors, e.g. in [TextField] fields. + final Color errorColor; + + /// The focus color used indicate that a component has the input focus. + final Color focusColor; + + /// The highlight color used during ink splash animations or to + /// indicate an item in a menu is selected. + final Color highlightColor; + + /// The color to use for hint text or placeholder text, e.g. in + /// [TextField] fields. + final Color hintColor; + + /// The hover color used to indicate when a pointer is hovering over a + /// component. + final Color hoverColor; + + /// The color of the selected tab indicator in a tab bar. + final Color indicatorColor; + /// The background color for major parts of the app (toolbars, tab bars, etc) /// /// The theme's [colorScheme] property contains [ColorScheme.primary], as @@ -1239,18 +1282,24 @@ class ThemeData with Diagnosticable { /// visuals in terms of the theme's [colorScheme]. final Color primaryColor; - /// A lighter version of the [primaryColor]. - final Color primaryColorLight; - /// A darker version of the [primaryColor]. final Color primaryColorDark; - /// The focus color used indicate that a component has the input focus. - final Color focusColor; + /// A lighter version of the [primaryColor]. + final Color primaryColorLight; - /// The hover color used to indicate when a pointer is hovering over a - /// component. - final Color hoverColor; + /// The default color of the [Material] that underlies the [Scaffold]. The + /// background color for a typical material app or a page within the app. + final Color scaffoldBackgroundColor; + + /// The color of the header of a [PaginatedDataTable] when there are selected rows. + // According to the spec for data tables: + // https://material.io/archive/guidelines/components/data-tables.html#data-tables-tables-within-cards + // ...this should be the "50-value of secondary app color". + final Color secondaryHeaderColor; + + /// The color used to highlight selected rows. + final Color selectedRowColor; /// The color that the [Material] widget uses to draw elevation shadows. /// @@ -1263,96 +1312,39 @@ class ThemeData with Diagnosticable { /// overlay on or off for dark themes. final Color shadowColor; - /// The default color of [MaterialType.canvas] [Material]. - final Color canvasColor; - - /// The default color of the [Material] that underlies the [Scaffold]. The - /// background color for a typical material app or a page within the app. - final Color scaffoldBackgroundColor; - - /// The default color of the [BottomAppBar]. - /// - /// This can be overridden by specifying [BottomAppBar.color]. - final Color bottomAppBarColor; - - /// The color of [Material] when it is used as a [Card]. - final Color cardColor; - - /// The color of [Divider]s and [PopupMenuDivider]s, also used - /// between [ListTile]s, between rows in [DataTable]s, and so forth. - /// - /// To create an appropriate [BorderSide] that uses this color, consider - /// [Divider.createBorderSide]. - final Color dividerColor; - - /// The highlight color used during ink splash animations or to - /// indicate an item in a menu is selected. - final Color highlightColor; - /// The color of ink splashes. /// /// See also: /// * [splashFactory], which defines the appearance of the splash. final Color splashColor; - /// The color used to highlight selected rows. - final Color selectedRowColor; + /// The color used to highlight the active states of toggleable widgets like + /// [Switch], [Radio], and [Checkbox]. + final Color toggleableActiveColor; /// The color used for widgets in their inactive (but enabled) /// state. For example, an unchecked checkbox. See also [disabledColor]. final Color unselectedWidgetColor; - /// The color used for widgets that are inoperative, regardless of - /// their state. For example, a disabled checkbox (which may be - /// checked or unchecked). - final Color disabledColor; - - /// The color of the header of a [PaginatedDataTable] when there are selected rows. - // According to the spec for data tables: - // https://material.io/archive/guidelines/components/data-tables.html#data-tables-tables-within-cards - // ...this should be the "50-value of secondary app color". - final Color secondaryHeaderColor; - - /// A color that contrasts with the [primaryColor], e.g. used as the - /// remaining part of a progress bar. - final Color backgroundColor; - - /// The background color of [Dialog] elements. - final Color dialogBackgroundColor; - - /// The color of the selected tab indicator in a tab bar. - final Color indicatorColor; - - /// The color to use for hint text or placeholder text, e.g. in - /// [TextField] fields. - final Color hintColor; - - /// The color to use for input validation errors, e.g. in [TextField] fields. - final Color errorColor; - - /// The color used to highlight the active states of toggleable widgets like - /// [Switch], [Radio], and [Checkbox]. - final Color toggleableActiveColor; - // TYPOGRAPHY & ICONOGRAPHY - /// The color and geometry [TextTheme] values used to configure [textTheme]. - /// - /// Defaults to a [platform]-appropriate typography. - final Typography typography; - - /// Text with a color that contrasts with the card and canvas colors. - final TextTheme textTheme; - - /// A text theme that contrasts with the primary color. - final TextTheme primaryTextTheme; - /// An icon theme that contrasts with the card and canvas colors. final IconThemeData iconTheme; /// An icon theme that contrasts with the primary color. final IconThemeData primaryIconTheme; + /// A text theme that contrasts with the primary color. + final TextTheme primaryTextTheme; + + /// Text with a color that contrasts with the card and canvas colors. + final TextTheme textTheme; + + /// The color and geometry [TextTheme] values used to configure [textTheme]. + /// + /// Defaults to a [platform]-appropriate typography. + final Typography typography; + // COMPONENT THEMES /// A theme for customizing the color, elevation, brightness, iconTheme and @@ -1410,6 +1402,9 @@ class ThemeData with Diagnosticable { /// [ElevatedButton]s. final ElevatedButtonThemeData elevatedButtonTheme; + /// A theme for customizing the visual properties of [ExpansionTile]s. + final ExpansionTileThemeData expansionTileTheme; + /// A theme for customizing the shape, elevation, and color of a /// [FloatingActionButton]. final FloatingActionButtonThemeData floatingActionButtonTheme; @@ -1471,9 +1466,6 @@ class ThemeData with Diagnosticable { /// This is the value returned from [TooltipTheme.of]. final TooltipThemeData tooltipTheme; - /// A theme for customizing the visual properties of [ExpansionTile]s. - final ExpansionTileThemeData expansionTileTheme; - // DEPRECATED (newest deprecations at the bottom) /// Obsolete property that was originally used as the foreground @@ -1591,10 +1583,36 @@ class ThemeData with Diagnosticable { Brightness get primaryColorBrightness => _primaryColorBrightness!; final Brightness? _primaryColorBrightness; + /// Specifies which overscroll indicator to use on [TargetPlatform.android]. + /// + /// When null, the default value of + /// [MaterialScrollBehavior.androidOverscrollIndicator] is + /// [AndroidOverscrollIndicator.glow]. + /// + /// This property is deprecated. Use the [useMaterial3] flag instead, or + /// override [ScrollBehavior.buildOverscrollIndicator]. + /// + /// See also: + /// + /// * [StretchingOverscrollIndicator], a Material Design edge effect + /// that transforms the contents of a scrollable when overscrolled. + /// * [GlowingOverscrollIndicator], an edge effect that paints a glow + /// over the contents of a scrollable when overscrolled. + @Deprecated( + 'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. ' + 'This feature was deprecated after v2.13.0-0.0.pre.' + ) + final AndroidOverscrollIndicator? androidOverscrollIndicator; + /// Creates a copy of this theme but with the given fields replaced with the new values. /// /// The [brightness] value is applied to the [colorScheme]. ThemeData copyWith({ + // For the sanity of the reader, make sure these properties are in the same + // order in every place that they are separated by section comments (e.g. + // GENERAL CONFIGURATION). Each section except for deprecations should be + // alphabetical by symbol name. + // GENERAL CONFIGURATION bool? applyElevationOverlayColor, NoDefaultCupertinoThemeData? cupertinoOverrideTheme, @@ -1605,43 +1623,43 @@ class ThemeData with Diagnosticable { TargetPlatform? platform, ScrollbarThemeData? scrollbarTheme, InteractiveInkFeatureFactory? splashFactory, - VisualDensity? visualDensity, bool? useMaterial3, + VisualDensity? visualDensity, // COLOR // [colorScheme] is the preferred way to configure colors. The other color // properties will gradually be phased out, see // https://github.com/flutter/flutter/issues/91772. - ColorScheme? colorScheme, - Brightness? brightness, - Color? primaryColor, - Color? primaryColorLight, - Color? primaryColorDark, - Color? focusColor, - Color? hoverColor, - Color? shadowColor, - Color? canvasColor, - Color? scaffoldBackgroundColor, - Color? bottomAppBarColor, - Color? cardColor, - Color? dividerColor, - Color? highlightColor, - Color? splashColor, - Color? selectedRowColor, - Color? unselectedWidgetColor, - Color? disabledColor, - Color? secondaryHeaderColor, Color? backgroundColor, + Color? bottomAppBarColor, + Brightness? brightness, + Color? canvasColor, + Color? cardColor, + ColorScheme? colorScheme, Color? dialogBackgroundColor, - Color? indicatorColor, - Color? hintColor, + Color? disabledColor, + Color? dividerColor, Color? errorColor, + Color? focusColor, + Color? highlightColor, + Color? hintColor, + Color? hoverColor, + Color? indicatorColor, + Color? primaryColor, + Color? primaryColorDark, + Color? primaryColorLight, + Color? scaffoldBackgroundColor, + Color? secondaryHeaderColor, + Color? selectedRowColor, + Color? shadowColor, + Color? splashColor, Color? toggleableActiveColor, + Color? unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY - Typography? typography, - TextTheme? textTheme, - TextTheme? primaryTextTheme, IconThemeData? iconTheme, IconThemeData? primaryIconTheme, + TextTheme? primaryTextTheme, + TextTheme? textTheme, + Typography? typography, // COMPONENT THEMES AppBarTheme? appBarTheme, MaterialBannerThemeData? bannerTheme, @@ -1658,6 +1676,7 @@ class ThemeData with Diagnosticable { DividerThemeData? dividerTheme, DrawerThemeData? drawerTheme, ElevatedButtonThemeData? elevatedButtonTheme, + ExpansionTileThemeData? expansionTileTheme, FloatingActionButtonThemeData? floatingActionButtonTheme, ListTileThemeData? listTileTheme, NavigationBarThemeData? navigationBarTheme, @@ -1675,7 +1694,6 @@ class ThemeData with Diagnosticable { TimePickerThemeData? timePickerTheme, ToggleButtonsThemeData? toggleButtonsTheme, TooltipThemeData? tooltipTheme, - ExpansionTileThemeData? expansionTileTheme, // DEPRECATED (newest deprecations at the bottom) @Deprecated( 'No longer used by the framework, please remove any reference to it. ' @@ -1728,6 +1746,11 @@ class ThemeData with Diagnosticable { }) { cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault(); return ThemeData.raw( + // For the sanity of the reader, make sure these properties are in the same + // order in every place that they are separated by section comments (e.g. + // GENERAL CONFIGURATION). Each section except for deprecations should be + // alphabetical by symbol name. + // GENERAL CONFIGURATION applyElevationOverlayColor: applyElevationOverlayColor ?? this.applyElevationOverlayColor, cupertinoOverrideTheme: cupertinoOverrideTheme ?? this.cupertinoOverrideTheme, @@ -1738,39 +1761,39 @@ class ThemeData with Diagnosticable { platform: platform ?? this.platform, scrollbarTheme: scrollbarTheme ?? this.scrollbarTheme, splashFactory: splashFactory ?? this.splashFactory, - visualDensity: visualDensity ?? this.visualDensity, useMaterial3: useMaterial3 ?? this.useMaterial3, + visualDensity: visualDensity ?? this.visualDensity, // COLOR - colorScheme: (colorScheme ?? this.colorScheme).copyWith(brightness: brightness), - primaryColor: primaryColor ?? this.primaryColor, - primaryColorLight: primaryColorLight ?? this.primaryColorLight, - primaryColorDark: primaryColorDark ?? this.primaryColorDark, - focusColor: focusColor ?? this.focusColor, - hoverColor: hoverColor ?? this.hoverColor, - shadowColor: shadowColor ?? this.shadowColor, - canvasColor: canvasColor ?? this.canvasColor, - scaffoldBackgroundColor: scaffoldBackgroundColor ?? this.scaffoldBackgroundColor, - bottomAppBarColor: bottomAppBarColor ?? this.bottomAppBarColor, - cardColor: cardColor ?? this.cardColor, - dividerColor: dividerColor ?? this.dividerColor, - highlightColor: highlightColor ?? this.highlightColor, - splashColor: splashColor ?? this.splashColor, - selectedRowColor: selectedRowColor ?? this.selectedRowColor, - unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor, - disabledColor: disabledColor ?? this.disabledColor, - secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor, backgroundColor: backgroundColor ?? this.backgroundColor, + bottomAppBarColor: bottomAppBarColor ?? this.bottomAppBarColor, + canvasColor: canvasColor ?? this.canvasColor, + cardColor: cardColor ?? this.cardColor, + colorScheme: (colorScheme ?? this.colorScheme).copyWith(brightness: brightness), dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor, - indicatorColor: indicatorColor ?? this.indicatorColor, - hintColor: hintColor ?? this.hintColor, + disabledColor: disabledColor ?? this.disabledColor, + dividerColor: dividerColor ?? this.dividerColor, errorColor: errorColor ?? this.errorColor, + focusColor: focusColor ?? this.focusColor, + highlightColor: highlightColor ?? this.highlightColor, + hintColor: hintColor ?? this.hintColor, + hoverColor: hoverColor ?? this.hoverColor, + indicatorColor: indicatorColor ?? this.indicatorColor, + primaryColor: primaryColor ?? this.primaryColor, + primaryColorDark: primaryColorDark ?? this.primaryColorDark, + primaryColorLight: primaryColorLight ?? this.primaryColorLight, + scaffoldBackgroundColor: scaffoldBackgroundColor ?? this.scaffoldBackgroundColor, + secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor, + selectedRowColor: selectedRowColor ?? this.selectedRowColor, + shadowColor: shadowColor ?? this.shadowColor, + splashColor: splashColor ?? this.splashColor, toggleableActiveColor: toggleableActiveColor ?? this.toggleableActiveColor, + unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY - typography: typography ?? this.typography, - textTheme: textTheme ?? this.textTheme, - primaryTextTheme: primaryTextTheme ?? this.primaryTextTheme, iconTheme: iconTheme ?? this.iconTheme, primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme, + primaryTextTheme: primaryTextTheme ?? this.primaryTextTheme, + textTheme: textTheme ?? this.textTheme, + typography: typography ?? this.typography, // COMPONENT THEMES appBarTheme: appBarTheme ?? this.appBarTheme, bannerTheme: bannerTheme ?? this.bannerTheme, @@ -1787,6 +1810,7 @@ class ThemeData with Diagnosticable { dividerTheme: dividerTheme ?? this.dividerTheme, drawerTheme: drawerTheme ?? this.drawerTheme, elevatedButtonTheme: elevatedButtonTheme ?? this.elevatedButtonTheme, + expansionTileTheme: expansionTileTheme ?? this.expansionTileTheme, floatingActionButtonTheme: floatingActionButtonTheme ?? this.floatingActionButtonTheme, listTileTheme: listTileTheme ?? this.listTileTheme, navigationBarTheme: navigationBarTheme ?? this.navigationBarTheme, @@ -1804,7 +1828,6 @@ class ThemeData with Diagnosticable { timePickerTheme: timePickerTheme ?? this.timePickerTheme, toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme, tooltipTheme: tooltipTheme ?? this.tooltipTheme, - expansionTileTheme: expansionTileTheme ?? this.expansionTileTheme, // DEPRECATED (newest deprecations at the bottom) accentColor: accentColor ?? this.accentColor, accentColorBrightness: accentColorBrightness ?? this.accentColorBrightness, @@ -1919,10 +1942,12 @@ class ThemeData with Diagnosticable { assert(a != null); assert(b != null); assert(t != null); - // Warning: make sure these properties are in the exact same order as in - // Object.hash() and in the raw constructor and in the order of fields in - // the class and in the lerp() method. return ThemeData.raw( + // For the sanity of the reader, make sure these properties are in the same + // order in every place that they are separated by section comments (e.g. + // GENERAL CONFIGURATION). Each section except for deprecations should be + // alphabetical by symbol name. + // GENERAL CONFIGURATION applyElevationOverlayColor:t < 0.5 ? a.applyElevationOverlayColor : b.applyElevationOverlayColor, cupertinoOverrideTheme:t < 0.5 ? a.cupertinoOverrideTheme : b.cupertinoOverrideTheme, @@ -1933,39 +1958,39 @@ class ThemeData with Diagnosticable { platform: t < 0.5 ? a.platform : b.platform, scrollbarTheme: ScrollbarThemeData.lerp(a.scrollbarTheme, b.scrollbarTheme, t), splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory, - visualDensity: VisualDensity.lerp(a.visualDensity, b.visualDensity, t), useMaterial3: t < 0.5 ? a.useMaterial3 : b.useMaterial3, + visualDensity: VisualDensity.lerp(a.visualDensity, b.visualDensity, t), // COLOR - colorScheme: ColorScheme.lerp(a.colorScheme, b.colorScheme, t), - primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t)!, - primaryColorLight: Color.lerp(a.primaryColorLight, b.primaryColorLight, t)!, - primaryColorDark: Color.lerp(a.primaryColorDark, b.primaryColorDark, t)!, - focusColor: Color.lerp(a.focusColor, b.focusColor, t)!, - hoverColor: Color.lerp(a.hoverColor, b.hoverColor, t)!, - shadowColor: Color.lerp(a.shadowColor, b.shadowColor, t)!, - canvasColor: Color.lerp(a.canvasColor, b.canvasColor, t)!, - scaffoldBackgroundColor: Color.lerp(a.scaffoldBackgroundColor, b.scaffoldBackgroundColor, t)!, - bottomAppBarColor: Color.lerp(a.bottomAppBarColor, b.bottomAppBarColor, t)!, - cardColor: Color.lerp(a.cardColor, b.cardColor, t)!, - dividerColor: Color.lerp(a.dividerColor, b.dividerColor, t)!, - highlightColor: Color.lerp(a.highlightColor, b.highlightColor, t)!, - splashColor: Color.lerp(a.splashColor, b.splashColor, t)!, - selectedRowColor: Color.lerp(a.selectedRowColor, b.selectedRowColor, t)!, - unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t)!, - disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t)!, - secondaryHeaderColor: Color.lerp(a.secondaryHeaderColor, b.secondaryHeaderColor, t)!, backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t)!, + bottomAppBarColor: Color.lerp(a.bottomAppBarColor, b.bottomAppBarColor, t)!, + canvasColor: Color.lerp(a.canvasColor, b.canvasColor, t)!, + cardColor: Color.lerp(a.cardColor, b.cardColor, t)!, + colorScheme: ColorScheme.lerp(a.colorScheme, b.colorScheme, t), dialogBackgroundColor: Color.lerp(a.dialogBackgroundColor, b.dialogBackgroundColor, t)!, - indicatorColor: Color.lerp(a.indicatorColor, b.indicatorColor, t)!, - hintColor: Color.lerp(a.hintColor, b.hintColor, t)!, + disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t)!, + dividerColor: Color.lerp(a.dividerColor, b.dividerColor, t)!, errorColor: Color.lerp(a.errorColor, b.errorColor, t)!, + focusColor: Color.lerp(a.focusColor, b.focusColor, t)!, + highlightColor: Color.lerp(a.highlightColor, b.highlightColor, t)!, + hintColor: Color.lerp(a.hintColor, b.hintColor, t)!, + hoverColor: Color.lerp(a.hoverColor, b.hoverColor, t)!, + indicatorColor: Color.lerp(a.indicatorColor, b.indicatorColor, t)!, + primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t)!, + primaryColorDark: Color.lerp(a.primaryColorDark, b.primaryColorDark, t)!, + primaryColorLight: Color.lerp(a.primaryColorLight, b.primaryColorLight, t)!, + scaffoldBackgroundColor: Color.lerp(a.scaffoldBackgroundColor, b.scaffoldBackgroundColor, t)!, + secondaryHeaderColor: Color.lerp(a.secondaryHeaderColor, b.secondaryHeaderColor, t)!, + selectedRowColor: Color.lerp(a.selectedRowColor, b.selectedRowColor, t)!, + shadowColor: Color.lerp(a.shadowColor, b.shadowColor, t)!, + splashColor: Color.lerp(a.splashColor, b.splashColor, t)!, toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t)!, + unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t)!, // TYPOGRAPHY & ICONOGRAPHY - typography: Typography.lerp(a.typography, b.typography, t), - textTheme: TextTheme.lerp(a.textTheme, b.textTheme, t), - primaryTextTheme: TextTheme.lerp(a.primaryTextTheme, b.primaryTextTheme, t), iconTheme: IconThemeData.lerp(a.iconTheme, b.iconTheme, t), primaryIconTheme: IconThemeData.lerp(a.primaryIconTheme, b.primaryIconTheme, t), + primaryTextTheme: TextTheme.lerp(a.primaryTextTheme, b.primaryTextTheme, t), + textTheme: TextTheme.lerp(a.textTheme, b.textTheme, t), + typography: Typography.lerp(a.typography, b.typography, t), // COMPONENT THEMES appBarTheme: AppBarTheme.lerp(a.appBarTheme, b.appBarTheme, t), bannerTheme: MaterialBannerThemeData.lerp(a.bannerTheme, b.bannerTheme, t), @@ -1982,6 +2007,7 @@ class ThemeData with Diagnosticable { dividerTheme: DividerThemeData.lerp(a.dividerTheme, b.dividerTheme, t), drawerTheme: DrawerThemeData.lerp(a.drawerTheme, b.drawerTheme, t)!, elevatedButtonTheme: ElevatedButtonThemeData.lerp(a.elevatedButtonTheme, b.elevatedButtonTheme, t)!, + expansionTileTheme: ExpansionTileThemeData.lerp(a.expansionTileTheme, b.expansionTileTheme, t)!, floatingActionButtonTheme: FloatingActionButtonThemeData.lerp(a.floatingActionButtonTheme, b.floatingActionButtonTheme, t)!, listTileTheme: ListTileThemeData.lerp(a.listTileTheme, b.listTileTheme, t)!, navigationBarTheme: NavigationBarThemeData.lerp(a.navigationBarTheme, b.navigationBarTheme, t)!, @@ -1999,7 +2025,6 @@ class ThemeData with Diagnosticable { timePickerTheme: TimePickerThemeData.lerp(a.timePickerTheme, b.timePickerTheme, t), toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t)!, tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t)!, - expansionTileTheme: ExpansionTileThemeData.lerp(a.expansionTileTheme, b.expansionTileTheme, t)!, // DEPRECATED (newest deprecations at the bottom) accentColor: Color.lerp(a.accentColor, b.accentColor, t), accentColorBrightness: t < 0.5 ? a.accentColorBrightness : b.accentColorBrightness, @@ -2016,10 +2041,12 @@ class ThemeData with Diagnosticable { bool operator ==(Object other) { if (other.runtimeType != runtimeType) return false; - // Warning: make sure these properties are in the exact same order as in - // Object.hash() and in the raw constructor and in the order of fields in - // the class and in the lerp() method. return other is ThemeData && + // For the sanity of the reader, make sure these properties are in the same + // order in every place that they are separated by section comments (e.g. + // GENERAL CONFIGURATION). Each section except for deprecations should be + // alphabetical by symbol name. + // GENERAL CONFIGURATION other.applyElevationOverlayColor == applyElevationOverlayColor && other.cupertinoOverrideTheme == cupertinoOverrideTheme && @@ -2030,39 +2057,39 @@ class ThemeData with Diagnosticable { other.platform == platform && other.scrollbarTheme == scrollbarTheme && other.splashFactory == splashFactory && - other.visualDensity == visualDensity && other.useMaterial3 == useMaterial3 && + other.visualDensity == visualDensity && // COLOR - other.colorScheme == colorScheme && - other.primaryColor == primaryColor && - other.primaryColorLight == primaryColorLight && - other.primaryColorDark == primaryColorDark && - other.focusColor == focusColor && - other.hoverColor == hoverColor && - other.shadowColor == shadowColor && - other.canvasColor == canvasColor && - other.scaffoldBackgroundColor == scaffoldBackgroundColor && - other.bottomAppBarColor == bottomAppBarColor && - other.cardColor == cardColor && - other.dividerColor == dividerColor && - other.highlightColor == highlightColor && - other.splashColor == splashColor && - other.selectedRowColor == selectedRowColor && - other.unselectedWidgetColor == unselectedWidgetColor && - other.disabledColor == disabledColor && - other.secondaryHeaderColor == secondaryHeaderColor && other.backgroundColor == backgroundColor && + other.bottomAppBarColor == bottomAppBarColor && + other.canvasColor == canvasColor && + other.cardColor == cardColor && + other.colorScheme == colorScheme && other.dialogBackgroundColor == dialogBackgroundColor && - other.indicatorColor == indicatorColor && - other.hintColor == hintColor && + other.disabledColor == disabledColor && + other.dividerColor == dividerColor && other.errorColor == errorColor && + other.focusColor == focusColor && + other.highlightColor == highlightColor && + other.hintColor == hintColor && + other.hoverColor == hoverColor && + other.indicatorColor == indicatorColor && + other.primaryColor == primaryColor && + other.primaryColorDark == primaryColorDark && + other.primaryColorLight == primaryColorLight && + other.scaffoldBackgroundColor == scaffoldBackgroundColor && + other.secondaryHeaderColor == secondaryHeaderColor && + other.selectedRowColor == selectedRowColor && + other.shadowColor == shadowColor && + other.splashColor == splashColor && other.toggleableActiveColor == toggleableActiveColor && + other.unselectedWidgetColor == unselectedWidgetColor && // TYPOGRAPHY & ICONOGRAPHY - other.typography == typography && - other.textTheme == textTheme && - other.primaryTextTheme == primaryTextTheme && other.iconTheme == iconTheme && other.primaryIconTheme == primaryIconTheme && + other.primaryTextTheme == primaryTextTheme && + other.textTheme == textTheme && + other.typography == typography && // COMPONENT THEMES other.appBarTheme == appBarTheme && other.bannerTheme == bannerTheme && @@ -2079,6 +2106,7 @@ class ThemeData with Diagnosticable { other.dividerTheme == dividerTheme && other.drawerTheme == drawerTheme && other.elevatedButtonTheme == elevatedButtonTheme && + other.expansionTileTheme == expansionTileTheme && other.floatingActionButtonTheme == floatingActionButtonTheme && other.listTileTheme == listTileTheme && other.navigationBarTheme == navigationBarTheme && @@ -2096,7 +2124,6 @@ class ThemeData with Diagnosticable { other.timePickerTheme == timePickerTheme && other.toggleButtonsTheme == toggleButtonsTheme && other.tooltipTheme == tooltipTheme && - other.expansionTileTheme == expansionTileTheme && // DEPRECATED (newest deprecations at the bottom) other.accentColor == accentColor && other.accentColorBrightness == accentColorBrightness && @@ -2110,10 +2137,12 @@ class ThemeData with Diagnosticable { @override int get hashCode { - // Warning: For the sanity of the reader, please make sure these properties - // are in the exact same order as in operator == and in the raw constructor - // and in the order of fields in the class and in the lerp() method. final List values = [ + // For the sanity of the reader, make sure these properties are in the same + // order in every place that they are separated by section comments (e.g. + // GENERAL CONFIGURATION). Each section except for deprecations should be + // alphabetical by symbol name. + // GENERAL CONFIGURATION applyElevationOverlayColor, cupertinoOverrideTheme, @@ -2125,39 +2154,39 @@ class ThemeData with Diagnosticable { platform, scrollbarTheme, splashFactory, - visualDensity, useMaterial3, + visualDensity, // COLOR - colorScheme, - primaryColor, - primaryColorLight, - primaryColorDark, - focusColor, - hoverColor, - shadowColor, - canvasColor, - scaffoldBackgroundColor, - bottomAppBarColor, - cardColor, - dividerColor, - highlightColor, - splashColor, - selectedRowColor, - unselectedWidgetColor, - disabledColor, - secondaryHeaderColor, backgroundColor, + bottomAppBarColor, + canvasColor, + cardColor, + colorScheme, dialogBackgroundColor, - indicatorColor, - hintColor, + disabledColor, + dividerColor, errorColor, + focusColor, + highlightColor, + hintColor, + hoverColor, + indicatorColor, + primaryColor, + primaryColorDark, + primaryColorLight, + scaffoldBackgroundColor, + secondaryHeaderColor, + selectedRowColor, + shadowColor, + splashColor, toggleableActiveColor, + unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY - typography, - textTheme, - primaryTextTheme, iconTheme, primaryIconTheme, + primaryTextTheme, + textTheme, + typography, // COMPONENT THEMES appBarTheme, bannerTheme, @@ -2174,6 +2203,7 @@ class ThemeData with Diagnosticable { dividerTheme, drawerTheme, elevatedButtonTheme, + expansionTileTheme, floatingActionButtonTheme, listTileTheme, navigationBarTheme, @@ -2191,7 +2221,6 @@ class ThemeData with Diagnosticable { timePickerTheme, toggleButtonsTheme, tooltipTheme, - expansionTileTheme, // DEPRECATED (newest deprecations at the bottom) accentColor, accentColorBrightness, @@ -2209,6 +2238,11 @@ class ThemeData with Diagnosticable { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); final ThemeData defaultData = ThemeData.fallback(); + // For the sanity of the reader, make sure these properties are in the same + // order in every place that they are separated by section comments (e.g. + // GENERAL CONFIGURATION). Each section except for deprecations should be + // alphabetical by symbol name. + // GENERAL CONFIGURATION properties.add(DiagnosticsProperty('applyElevationOverlayColor', applyElevationOverlayColor, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('cupertinoOverrideTheme', cupertinoOverrideTheme, defaultValue: defaultData.cupertinoOverrideTheme, level: DiagnosticLevel.debug)); @@ -2219,39 +2253,39 @@ class ThemeData with Diagnosticable { properties.add(EnumProperty('platform', platform, defaultValue: defaultTargetPlatform, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('scrollbarTheme', scrollbarTheme, defaultValue: defaultData.scrollbarTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('splashFactory', splashFactory, defaultValue: defaultData.splashFactory, level: DiagnosticLevel.debug)); - properties.add(DiagnosticsProperty('visualDensity', visualDensity, defaultValue: defaultData.visualDensity, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('useMaterial3', useMaterial3, defaultValue: defaultData.useMaterial3, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('visualDensity', visualDensity, defaultValue: defaultData.visualDensity, level: DiagnosticLevel.debug)); // COLORS - properties.add(DiagnosticsProperty('colorScheme', colorScheme, defaultValue: defaultData.colorScheme, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('primaryColor', primaryColor, defaultValue: defaultData.primaryColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('primaryColorLight', primaryColorLight, defaultValue: defaultData.primaryColorLight, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('primaryColorDark', primaryColorDark, defaultValue: defaultData.primaryColorDark, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('focusColor', focusColor, defaultValue: defaultData.focusColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('hoverColor', hoverColor, defaultValue: defaultData.hoverColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('shadowColor', shadowColor, defaultValue: defaultData.shadowColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('canvasColor', canvasColor, defaultValue: defaultData.canvasColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('scaffoldBackgroundColor', scaffoldBackgroundColor, defaultValue: defaultData.scaffoldBackgroundColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('bottomAppBarColor', bottomAppBarColor, defaultValue: defaultData.bottomAppBarColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('cardColor', cardColor, defaultValue: defaultData.cardColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('dividerColor', dividerColor, defaultValue: defaultData.dividerColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('highlightColor', highlightColor, defaultValue: defaultData.highlightColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('splashColor', splashColor, defaultValue: defaultData.splashColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('selectedRowColor', selectedRowColor, defaultValue: defaultData.selectedRowColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('unselectedWidgetColor', unselectedWidgetColor, defaultValue: defaultData.unselectedWidgetColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('disabledColor', disabledColor, defaultValue: defaultData.disabledColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('secondaryHeaderColor', secondaryHeaderColor, defaultValue: defaultData.secondaryHeaderColor, level: DiagnosticLevel.debug)); properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('bottomAppBarColor', bottomAppBarColor, defaultValue: defaultData.bottomAppBarColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('canvasColor', canvasColor, defaultValue: defaultData.canvasColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('cardColor', cardColor, defaultValue: defaultData.cardColor, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('colorScheme', colorScheme, defaultValue: defaultData.colorScheme, level: DiagnosticLevel.debug)); properties.add(ColorProperty('dialogBackgroundColor', dialogBackgroundColor, defaultValue: defaultData.dialogBackgroundColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('indicatorColor', indicatorColor, defaultValue: defaultData.indicatorColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('hintColor', hintColor, defaultValue: defaultData.hintColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('disabledColor', disabledColor, defaultValue: defaultData.disabledColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('dividerColor', dividerColor, defaultValue: defaultData.dividerColor, level: DiagnosticLevel.debug)); properties.add(ColorProperty('errorColor', errorColor, defaultValue: defaultData.errorColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('focusColor', focusColor, defaultValue: defaultData.focusColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('highlightColor', highlightColor, defaultValue: defaultData.highlightColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('hintColor', hintColor, defaultValue: defaultData.hintColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('hoverColor', hoverColor, defaultValue: defaultData.hoverColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('indicatorColor', indicatorColor, defaultValue: defaultData.indicatorColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('primaryColorDark', primaryColorDark, defaultValue: defaultData.primaryColorDark, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('primaryColorLight', primaryColorLight, defaultValue: defaultData.primaryColorLight, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('primaryColor', primaryColor, defaultValue: defaultData.primaryColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('scaffoldBackgroundColor', scaffoldBackgroundColor, defaultValue: defaultData.scaffoldBackgroundColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('secondaryHeaderColor', secondaryHeaderColor, defaultValue: defaultData.secondaryHeaderColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('selectedRowColor', selectedRowColor, defaultValue: defaultData.selectedRowColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('shadowColor', shadowColor, defaultValue: defaultData.shadowColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('splashColor', splashColor, defaultValue: defaultData.splashColor, level: DiagnosticLevel.debug)); properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('unselectedWidgetColor', unselectedWidgetColor, defaultValue: defaultData.unselectedWidgetColor, level: DiagnosticLevel.debug)); // TYPOGRAPHY & ICONOGRAPHY - properties.add(DiagnosticsProperty('typography', typography, defaultValue: defaultData.typography, level: DiagnosticLevel.debug)); - properties.add(DiagnosticsProperty('textTheme', textTheme, level: DiagnosticLevel.debug)); - properties.add(DiagnosticsProperty('primaryTextTheme', primaryTextTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('iconTheme', iconTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('primaryIconTheme', primaryIconTheme, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('primaryTextTheme', primaryTextTheme, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('textTheme', textTheme, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('typography', typography, defaultValue: defaultData.typography, level: DiagnosticLevel.debug)); // COMPONENT THEMES properties.add(DiagnosticsProperty('appBarTheme', appBarTheme, defaultValue: defaultData.appBarTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('bannerTheme', bannerTheme, defaultValue: defaultData.bannerTheme, level: DiagnosticLevel.debug)); @@ -2268,6 +2302,7 @@ class ThemeData with Diagnosticable { properties.add(DiagnosticsProperty('dividerTheme', dividerTheme, defaultValue: defaultData.dividerTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('drawerTheme', drawerTheme, defaultValue: defaultData.drawerTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('elevatedButtonTheme', elevatedButtonTheme, defaultValue: defaultData.elevatedButtonTheme, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('expansionTileTheme', expansionTileTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('floatingActionButtonTheme', floatingActionButtonTheme, defaultValue: defaultData.floatingActionButtonTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('listTileTheme', listTileTheme, defaultValue: defaultData.listTileTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('navigationBarTheme', navigationBarTheme, defaultValue: defaultData.navigationBarTheme, level: DiagnosticLevel.debug)); @@ -2285,7 +2320,6 @@ class ThemeData with Diagnosticable { properties.add(DiagnosticsProperty('timePickerTheme', timePickerTheme, defaultValue: defaultData.timePickerTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('toggleButtonsTheme', toggleButtonsTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('tooltipTheme', tooltipTheme, level: DiagnosticLevel.debug)); - properties.add(DiagnosticsProperty('expansionTileTheme', expansionTileTheme, level: DiagnosticLevel.debug)); // DEPRECATED (newest deprecations at the bottom) properties.add(ColorProperty('accentColor', accentColor, defaultValue: defaultData.accentColor, level: DiagnosticLevel.debug)); properties.add(EnumProperty('accentColorBrightness', accentColorBrightness, defaultValue: defaultData.accentColorBrightness, level: DiagnosticLevel.debug)); diff --git a/packages/flutter/test/material/theme_data_test.dart b/packages/flutter/test/material/theme_data_test.dart index 6139f622a6..b9ac657908 100644 --- a/packages/flutter/test/material/theme_data_test.dart +++ b/packages/flutter/test/material/theme_data_test.dart @@ -616,86 +616,96 @@ void main() { ); final ThemeData theme = ThemeData.raw( - visualDensity: VisualDensity.standard, - primaryColor: Colors.black, - primaryColorBrightness: Brightness.dark, - primaryColorLight: Colors.black, - primaryColorDark: Colors.black, - accentColor: Colors.black, - accentColorBrightness: Brightness.dark, - canvasColor: Colors.black, - shadowColor: Colors.black, - scaffoldBackgroundColor: Colors.black, - bottomAppBarColor: Colors.black, - cardColor: Colors.black, - dividerColor: Colors.black, - focusColor: Colors.black, - hoverColor: Colors.black, - highlightColor: Colors.black, - splashColor: Colors.black, + // For the sanity of the reader, make sure these properties are in the same + // order everywhere that they are separated by section comments (e.g. + // GENERAL CONFIGURATION). Each section except for deprecations should be + // alphabetical by symbol name. + + // GENERAL CONFIGURATION + applyElevationOverlayColor: false, + cupertinoOverrideTheme: null, + extensions: const >{}, + inputDecorationTheme: ThemeData.dark().inputDecorationTheme.copyWith(border: const OutlineInputBorder()), + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + pageTransitionsTheme: pageTransitionTheme, + platform: TargetPlatform.iOS, + scrollbarTheme: const ScrollbarThemeData(radius: Radius.circular(10.0)), splashFactory: InkRipple.splashFactory, useMaterial3: false, - selectedRowColor: Colors.black, - unselectedWidgetColor: Colors.black, - disabledColor: Colors.black, - buttonTheme: const ButtonThemeData(colorScheme: ColorScheme.dark()), - toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.black)), - buttonColor: Colors.black, - secondaryHeaderColor: Colors.black, + visualDensity: VisualDensity.standard, + // COLOR backgroundColor: Colors.black, + bottomAppBarColor: Colors.black, + canvasColor: Colors.black, + cardColor: Colors.black, + colorScheme: const ColorScheme.light(), dialogBackgroundColor: Colors.black, - indicatorColor: Colors.black, - hintColor: Colors.black, + disabledColor: Colors.black, + dividerColor: Colors.black, errorColor: Colors.black, + focusColor: Colors.black, + highlightColor: Colors.black, + hintColor: Colors.black, + hoverColor: Colors.black, + indicatorColor: Colors.black, + primaryColor: Colors.black, + primaryColorDark: Colors.black, + primaryColorLight: Colors.black, + scaffoldBackgroundColor: Colors.black, + secondaryHeaderColor: Colors.black, + selectedRowColor: Colors.black, + shadowColor: Colors.black, + splashColor: Colors.black, toggleableActiveColor: Colors.black, - textTheme: ThemeData.dark().textTheme, - primaryTextTheme: ThemeData.dark().textTheme, - accentTextTheme: ThemeData.dark().textTheme, - inputDecorationTheme: ThemeData.dark().inputDecorationTheme.copyWith(border: const OutlineInputBorder()), + unselectedWidgetColor: Colors.black, + // TYPOGRAPHY & ICONOGRAPHY iconTheme: ThemeData.dark().iconTheme, primaryIconTheme: ThemeData.dark().iconTheme, - accentIconTheme: ThemeData.dark().iconTheme, - sliderTheme: sliderTheme, - tabBarTheme: const TabBarTheme(labelColor: Colors.black), - tooltipTheme: const TooltipThemeData(height: 100), - expansionTileTheme: const ExpansionTileThemeData(backgroundColor: Colors.black), - cardTheme: const CardTheme(color: Colors.black), - chipTheme: chipTheme, - platform: TargetPlatform.iOS, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - applyElevationOverlayColor: false, - pageTransitionsTheme: pageTransitionTheme, + primaryTextTheme: ThemeData.dark().textTheme, + textTheme: ThemeData.dark().textTheme, + typography: Typography.material2018(), + // COMPONENT THEMES appBarTheme: const AppBarTheme(backgroundColor: Colors.black), - scrollbarTheme: const ScrollbarThemeData(radius: Radius.circular(10.0)), + bannerTheme: const MaterialBannerThemeData(backgroundColor: Colors.black), bottomAppBarTheme: const BottomAppBarTheme(color: Colors.black), - colorScheme: const ColorScheme.light(), + bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.fixed), + bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.black), + buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.start), + buttonTheme: const ButtonThemeData(colorScheme: ColorScheme.dark()), + cardTheme: const CardTheme(color: Colors.black), + checkboxTheme: const CheckboxThemeData(), + chipTheme: chipTheme, + dataTableTheme: const DataTableThemeData(), dialogTheme: const DialogTheme(backgroundColor: Colors.black), + dividerTheme: const DividerThemeData(color: Colors.black), + drawerTheme: const DrawerThemeData(), + elevatedButtonTheme: ElevatedButtonThemeData(style: ElevatedButton.styleFrom(primary: Colors.green)), + expansionTileTheme: const ExpansionTileThemeData(backgroundColor: Colors.black), floatingActionButtonTheme: const FloatingActionButtonThemeData(backgroundColor: Colors.black), + listTileTheme: const ListTileThemeData(), navigationBarTheme: const NavigationBarThemeData(backgroundColor: Colors.black), navigationRailTheme: const NavigationRailThemeData(backgroundColor: Colors.black), - typography: Typography.material2018(), - cupertinoOverrideTheme: null, - snackBarTheme: const SnackBarThemeData(backgroundColor: Colors.black), - bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.black), - popupMenuTheme: const PopupMenuThemeData(color: Colors.black), - bannerTheme: const MaterialBannerThemeData(backgroundColor: Colors.black), - dividerTheme: const DividerThemeData(color: Colors.black), - buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.start), - bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.fixed), - timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.black), - textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(primary: Colors.red)), - elevatedButtonTheme: ElevatedButtonThemeData(style: ElevatedButton.styleFrom(primary: Colors.green)), outlinedButtonTheme: OutlinedButtonThemeData(style: OutlinedButton.styleFrom(primary: Colors.blue)), - textSelectionTheme: const TextSelectionThemeData(cursorColor: Colors.black), - dataTableTheme: const DataTableThemeData(), - checkboxTheme: const CheckboxThemeData(), - radioTheme: const RadioThemeData(), - switchTheme: const SwitchThemeData(), + popupMenuTheme: const PopupMenuThemeData(color: Colors.black), progressIndicatorTheme: const ProgressIndicatorThemeData(), - drawerTheme: const DrawerThemeData(), - listTileTheme: const ListTileThemeData(), + radioTheme: const RadioThemeData(), + sliderTheme: sliderTheme, + snackBarTheme: const SnackBarThemeData(backgroundColor: Colors.black), + switchTheme: const SwitchThemeData(), + tabBarTheme: const TabBarTheme(labelColor: Colors.black), + textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(primary: Colors.red)), + textSelectionTheme: const TextSelectionThemeData(cursorColor: Colors.black), + timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.black), + toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.black)), + tooltipTheme: const TooltipThemeData(height: 100), + // DEPRECATED (newest deprecations at the bottom) + accentColor: Colors.black, + accentColorBrightness: Brightness.dark, + accentTextTheme: ThemeData.dark().textTheme, + accentIconTheme: ThemeData.dark().iconTheme, + buttonColor: Colors.black, fixTextFieldOutlineLabel: false, - extensions: const >{}, + primaryColorBrightness: Brightness.dark, ); final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors(