theme_data.dart 124 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import 'dart:ui' show Color, lerpDouble;
6

xster's avatar
xster committed
7
import 'package:flutter/cupertino.dart';
8 9
import 'package:flutter/foundation.dart';

10 11
import 'action_buttons.dart';
import 'action_icons_theme.dart';
12
import 'app_bar_theme.dart';
13
import 'badge_theme.dart';
14
import 'banner_theme.dart';
15
import 'bottom_app_bar_theme.dart';
16
import 'bottom_navigation_bar_theme.dart';
17
import 'bottom_sheet_theme.dart';
18
import 'button_bar_theme.dart';
19
import 'button_theme.dart';
20
import 'card_theme.dart';
21
import 'checkbox_theme.dart';
22
import 'chip_theme.dart';
23
import 'color_scheme.dart';
24
import 'colors.dart';
25
import 'constants.dart';
26
import 'data_table_theme.dart';
27
import 'date_picker_theme.dart';
28
import 'dialog_theme.dart';
29
import 'divider_theme.dart';
30
import 'drawer_theme.dart';
31
import 'dropdown_menu_theme.dart';
32
import 'elevated_button_theme.dart';
33
import 'expansion_tile_theme.dart';
34
import 'filled_button_theme.dart';
35
import 'floating_action_button_theme.dart';
36
import 'icon_button_theme.dart';
37
import 'ink_ripple.dart';
38
import 'ink_sparkle.dart';
39 40
import 'ink_splash.dart';
import 'ink_well.dart' show InteractiveInkFeatureFactory;
41
import 'input_decorator.dart';
42
import 'list_tile.dart';
43
import 'list_tile_theme.dart';
44 45 46
import 'menu_bar_theme.dart';
import 'menu_button_theme.dart';
import 'menu_theme.dart';
47
import 'navigation_bar_theme.dart';
hangyu's avatar
hangyu committed
48
import 'navigation_drawer_theme.dart';
49
import 'navigation_rail_theme.dart';
50
import 'outlined_button_theme.dart';
51
import 'page_transitions_theme.dart';
52
import 'popup_menu_theme.dart';
53
import 'progress_indicator_theme.dart';
54
import 'radio_theme.dart';
55
import 'scrollbar_theme.dart';
56
import 'search_bar_theme.dart';
57
import 'search_view_theme.dart';
58
import 'segmented_button_theme.dart';
59
import 'slider_theme.dart';
60
import 'snack_bar_theme.dart';
61
import 'switch_theme.dart';
62
import 'tab_bar_theme.dart';
63
import 'text_button_theme.dart';
64
import 'text_selection_theme.dart';
65
import 'text_theme.dart';
66
import 'time_picker_theme.dart';
67
import 'toggle_buttons_theme.dart';
68
import 'tooltip_theme.dart';
Adam Barth's avatar
Adam Barth committed
69
import 'typography.dart';
70

71
export 'package:flutter/services.dart' show Brightness;
72

73 74 75
// Examples can assume:
// late BuildContext context;

76 77
/// An interface that defines custom additions to a [ThemeData] object.
///
78 79
/// {@youtube 560 315 https://www.youtube.com/watch?v=8-szcYzFVao}
///
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
/// Typically used for custom colors. To use, subclass [ThemeExtension],
/// define a number of fields (e.g. [Color]s), and implement the [copyWith] and
/// [lerp] methods. The latter will ensure smooth transitions of properties when
/// switching themes.
///
/// {@tool dartpad}
/// This sample shows how to create and use a subclass of [ThemeExtension] that
/// defines two colors.
///
/// ** See code in examples/api/lib/material/theme/theme_extension.1.dart **
/// {@end-tool}
abstract class ThemeExtension<T extends ThemeExtension<T>> {
  /// Enable const constructor for subclasses.
  const ThemeExtension();

  /// The extension's type.
  Object get type => T;

  /// Creates a copy of this theme extension with the given fields
  /// replaced by the non-null parameter values.
  ThemeExtension<T> copyWith();

  /// Linearly interpolate with another [ThemeExtension] object.
  ///
  /// {@macro dart.ui.shadow.lerp}
105
  ThemeExtension<T> lerp(covariant ThemeExtension<T>? other, double t);
106 107
}

108 109 110 111 112
// Deriving these values is black magic. The spec claims that pressed buttons
// have a highlight of 0x66999999, but that's clearly wrong. The videos in the
// spec show that buttons have a composited highlight of #E1E1E1 on a background
// of #FAFAFA. Assuming that the highlight really has an opacity of 0x66, we can
// solve for the actual color of the highlight:
113
const Color _kLightThemeHighlightColor = Color(0x66BCBCBC);
114 115 116 117

// The same video shows the splash compositing to #D7D7D7 on a background of
// #E1E1E1. Again, assuming the splash has an opacity of 0x66, we can solve for
// the actual color of the splash:
118
const Color _kLightThemeSplashColor = Color(0x66C8C8C8);
119 120 121

// Unfortunately, a similar video isn't available for the dark theme, which
// means we assume the values in the spec are actually correct.
122 123
const Color _kDarkThemeHighlightColor = Color(0x40CCCCCC);
const Color _kDarkThemeSplashColor = Color(0x40CCCCCC);
124

125 126 127 128 129 130 131 132 133
/// Configures the tap target and layout size of certain Material widgets.
///
/// Changing the value in [ThemeData.materialTapTargetSize] will affect the
/// accessibility experience.
///
/// Some of the impacted widgets include:
///
///   * [FloatingActionButton], only the mini tap target size is increased.
///   * [MaterialButton]
134 135 136
///   * [OutlinedButton]
///   * [TextButton]
///   * [ElevatedButton]
137
///   * [IconButton]
138
///   * The time picker widget ([showTimePicker])
139 140 141 142 143 144 145 146 147 148 149 150 151
///   * [SnackBar]
///   * [Chip]
///   * [RawChip]
///   * [InputChip]
///   * [ChoiceChip]
///   * [FilterChip]
///   * [ActionChip]
///   * [Radio]
///   * [Switch]
///   * [Checkbox]
enum MaterialTapTargetSize {
  /// Expands the minimum tap target size to 48px by 48px.
  ///
152
  /// This is the default value of [ThemeData.materialTapTargetSize] and the
153 154 155 156 157 158 159 160 161
  /// recommended size to conform to Android accessibility scanner
  /// recommendations.
  padded,

  /// Shrinks the tap target size to the minimum provided by the Material
  /// specification.
  shrinkWrap,
}

162 163
/// Defines the configuration of the overall visual [Theme] for a [MaterialApp]
/// or a widget subtree within the app.
164
///
165
/// The [MaterialApp] theme property can be used to configure the appearance
166
/// of the entire app. Widget subtrees within an app can override the app's
167
/// theme by including a [Theme] widget at the top of the subtree.
168
///
169 170 171 172
/// Widgets whose appearance should align with the overall theme can obtain the
/// current theme's configuration with [Theme.of]. Material components typically
/// depend exclusively on the [colorScheme] and [textTheme]. These properties
/// are guaranteed to have non-null values.
173
///
174 175 176 177 178 179 180
/// The static [Theme.of] method finds the [ThemeData] value specified for the
/// nearest [BuildContext] ancestor. This lookup is inexpensive, essentially
/// just a single HashMap access. It can sometimes be a little confusing
/// because [Theme.of] can not see a [Theme] widget that is defined in the
/// current build method's context. To overcome that, create a new custom widget
/// for the subtree that appears below the new [Theme], or insert a widget
/// that creates a new BuildContext, like [Builder].
181
///
182 183 184 185 186 187 188 189 190
/// {@tool dartpad}
/// This example demonstrates how a typical [MaterialApp] specifies
/// and uses a custom [Theme]. The theme's [ColorScheme] is based on a
/// single "seed" color and configures itself to match the platform's
/// current light or dark color configuration. The theme overrides the
/// default configuration of [FloatingActionButton] to show how to
/// customize the appearance a class of components.
///
/// ** See code in examples/api/lib/material/theme_data/theme_data.0.dart **
191
/// {@end-tool}
192 193 194 195
///
/// See <https://material.io/design/color/> for
/// more discussion on how to pick the right colors.

196
@immutable
197
class ThemeData with Diagnosticable {
198
  /// Create a [ThemeData] that's used to configure a [Theme].
199
  ///
200 201 202
  /// The [colorScheme] and [textTheme] are used by the Material components to
  /// compute default values for visual properties. The API documentation for
  /// each component widget explains exactly how the defaults are computed.
203
  ///
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
  /// When providing a [ColorScheme], apps can either provide one directly
  /// with the [colorScheme] parameter, or have one generated for them by
  /// using the [colorSchemeSeed] and [brightness] parameters. A generated
  /// color scheme will be based on the tones of [colorSchemeSeed] and all of
  /// its contrasting color will meet accessibility guidelines for readability.
  /// (See [ColorScheme.fromSeed] for more details.)
  ///
  /// If the app wants to customize a generated color scheme, it can use
  /// [ColorScheme.fromSeed] directly and then [ColorScheme.copyWith] on the
  /// result to override any colors that need to be replaced. The result of
  /// this can be used as the [colorScheme] directly.
  ///
  /// For historical reasons, instead of using a [colorSchemeSeed] or
  /// [colorScheme], you can provide either a [primaryColor] or [primarySwatch]
  /// to construct the [colorScheme], but the results will not be as complete
  /// as when using generation from a seed color.
  ///
  /// If [colorSchemeSeed] is non-null then [colorScheme], [primaryColor] and
  /// [primarySwatch] must all be null.
  ///
224 225
  /// The [textTheme] [TextStyle] colors are black if the color scheme's
  /// brightness is [Brightness.light], and white for [Brightness.dark].
226
  ///
227 228 229
  /// To override the appearance of specific components, provide
  /// a component theme parameter like [sliderTheme], [toggleButtonsTheme],
  /// or [bottomNavigationBarTheme].
230
  ///
231
  /// See also:
232
  ///
233 234 235
  ///  * [ThemeData.from], which creates a ThemeData from a [ColorScheme].
  ///  * [ThemeData.light], which creates a light blue theme.
  ///  * [ThemeData.dark], which creates dark theme with a teal secondary [ColorScheme] color.
236
  ///  * [ColorScheme.fromSeed], which is used to create a [ColorScheme] from a seed color.
237
  factory ThemeData({
238 239 240 241 242
    // 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.

243 244 245
    // GENERAL CONFIGURATION
    bool? applyElevationOverlayColor,
    NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
246
    Iterable<ThemeExtension<dynamic>>? extensions,
247 248 249 250 251 252
    InputDecorationTheme? inputDecorationTheme,
    MaterialTapTargetSize? materialTapTargetSize,
    PageTransitionsTheme? pageTransitionsTheme,
    TargetPlatform? platform,
    ScrollbarThemeData? scrollbarTheme,
    InteractiveInkFeatureFactory? splashFactory,
253
    bool? useMaterial3,
254
    VisualDensity? visualDensity,
255 256
    // COLOR
    // [colorScheme] is the preferred way to configure colors. The other color
257 258
    // properties (as well as primarySwatch) will gradually be phased out, see
    // https://github.com/flutter/flutter/issues/91772.
259 260
    Brightness? brightness,
    Color? canvasColor,
261
    Color? cardColor,
262 263 264 265
    ColorScheme? colorScheme,
    Color? colorSchemeSeed,
    Color? dialogBackgroundColor,
    Color? disabledColor,
266
    Color? dividerColor,
267
    Color? focusColor,
268
    Color? highlightColor,
269
    Color? hintColor,
270 271 272 273 274 275 276 277 278 279 280
    Color? hoverColor,
    Color? indicatorColor,
    Color? primaryColor,
    Color? primaryColorDark,
    Color? primaryColorLight,
    MaterialColor? primarySwatch,
    Color? scaffoldBackgroundColor,
    Color? secondaryHeaderColor,
    Color? shadowColor,
    Color? splashColor,
    Color? unselectedWidgetColor,
281 282
    // TYPOGRAPHY & ICONOGRAPHY
    String? fontFamily,
283 284
    List<String>? fontFamilyFallback,
    String? package,
285 286
    IconThemeData? iconTheme,
    IconThemeData? primaryIconTheme,
287 288 289
    TextTheme? primaryTextTheme,
    TextTheme? textTheme,
    Typography? typography,
290
    // COMPONENT THEMES
291
    ActionIconThemeData? actionIconTheme,
292
    AppBarTheme? appBarTheme,
293
    BadgeThemeData? badgeTheme,
294 295 296 297 298 299 300 301 302 303
    MaterialBannerThemeData? bannerTheme,
    BottomAppBarTheme? bottomAppBarTheme,
    BottomNavigationBarThemeData? bottomNavigationBarTheme,
    BottomSheetThemeData? bottomSheetTheme,
    ButtonBarThemeData? buttonBarTheme,
    ButtonThemeData? buttonTheme,
    CardTheme? cardTheme,
    CheckboxThemeData? checkboxTheme,
    ChipThemeData? chipTheme,
    DataTableThemeData? dataTableTheme,
304
    DatePickerThemeData? datePickerTheme,
305 306 307
    DialogTheme? dialogTheme,
    DividerThemeData? dividerTheme,
    DrawerThemeData? drawerTheme,
308
    DropdownMenuThemeData? dropdownMenuTheme,
309
    ElevatedButtonThemeData? elevatedButtonTheme,
310
    ExpansionTileThemeData? expansionTileTheme,
311
    FilledButtonThemeData? filledButtonTheme,
312
    FloatingActionButtonThemeData? floatingActionButtonTheme,
313
    IconButtonThemeData? iconButtonTheme,
314
    ListTileThemeData? listTileTheme,
315 316 317
    MenuBarThemeData? menuBarTheme,
    MenuButtonThemeData? menuButtonTheme,
    MenuThemeData? menuTheme,
318
    NavigationBarThemeData? navigationBarTheme,
hangyu's avatar
hangyu committed
319
    NavigationDrawerThemeData? navigationDrawerTheme,
320 321 322 323 324
    NavigationRailThemeData? navigationRailTheme,
    OutlinedButtonThemeData? outlinedButtonTheme,
    PopupMenuThemeData? popupMenuTheme,
    ProgressIndicatorThemeData? progressIndicatorTheme,
    RadioThemeData? radioTheme,
325
    SearchBarThemeData? searchBarTheme,
326
    SearchViewThemeData? searchViewTheme,
327
    SegmentedButtonThemeData? segmentedButtonTheme,
328 329 330 331 332 333 334 335 336 337
    SliderThemeData? sliderTheme,
    SnackBarThemeData? snackBarTheme,
    SwitchThemeData? switchTheme,
    TabBarTheme? tabBarTheme,
    TextButtonThemeData? textButtonTheme,
    TextSelectionThemeData? textSelectionTheme,
    TimePickerThemeData? timePickerTheme,
    ToggleButtonsThemeData? toggleButtonsTheme,
    TooltipThemeData? tooltipTheme,
    // DEPRECATED (newest deprecations at the bottom)
338 339 340 341 342
    @Deprecated(
      'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
      'This feature was deprecated after v2.13.0-0.0.pre.'
    )
    AndroidOverscrollIndicator? androidOverscrollIndicator,
343 344 345 346
    @Deprecated(
      'No longer used by the framework, please remove any reference to it. '
      'For more information, consult the migration guide at '
      'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
347
      'This feature was deprecated after v3.4.0-19.0.pre.',
348 349
    )
    Color? toggleableActiveColor,
350 351 352 353 354
    @Deprecated(
      'No longer used by the framework, please remove any reference to it. '
      'This feature was deprecated after v3.1.0-0.0.pre.',
    )
    Color? selectedRowColor,
355 356 357 358 359 360 361 362 363 364
    @Deprecated(
      'Use colorScheme.error instead. '
      'This feature was deprecated after v3.3.0-0.5.pre.',
    )
    Color? errorColor,
    @Deprecated(
      'Use colorScheme.background instead. '
      'This feature was deprecated after v3.3.0-0.5.pre.',
    )
    Color? backgroundColor,
365 366 367 368 369
    @Deprecated(
      'Use BottomAppBarTheme.color instead. '
      'This feature was deprecated after v3.3.0-0.6.pre.',
    )
    Color? bottomAppBarColor,
370
  }) {
371 372
    // GENERAL CONFIGURATION
    cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
373
    extensions ??= <ThemeExtension<dynamic>>[];
374 375 376 377 378 379 380 381 382 383 384 385 386 387
    inputDecorationTheme ??= const InputDecorationTheme();
    platform ??= defaultTargetPlatform;
    switch (platform) {
      case TargetPlatform.android:
      case TargetPlatform.fuchsia:
      case TargetPlatform.iOS:
        materialTapTargetSize ??= MaterialTapTargetSize.padded;
      case TargetPlatform.linux:
      case TargetPlatform.macOS:
      case TargetPlatform.windows:
         materialTapTargetSize ??= MaterialTapTargetSize.shrinkWrap;
    }
    pageTransitionsTheme ??= const PageTransitionsTheme();
    scrollbarTheme ??= const ScrollbarThemeData();
388
    visualDensity ??= VisualDensity.defaultDensityForPlatform(platform);
389
    useMaterial3 ??= true;
390
    final bool useInkSparkle = platform == TargetPlatform.android && !kIsWeb;
391 392 393
    splashFactory ??= useMaterial3
      ? useInkSparkle ? InkSparkle.splashFactory : InkRipple.splashFactory
      : InkSplash.splashFactory;
394 395

    // COLOR
396
    assert(colorScheme?.brightness == null || brightness == null || colorScheme!.brightness == brightness);
397 398 399
    assert(colorSchemeSeed == null || colorScheme == null);
    assert(colorSchemeSeed == null || primarySwatch == null);
    assert(colorSchemeSeed == null || primaryColor == null);
400 401
    final Brightness effectiveBrightness = brightness ?? colorScheme?.brightness ?? Brightness.light;
    final bool isDark = effectiveBrightness == Brightness.dark;
402 403 404 405 406
    if (colorSchemeSeed != null || useMaterial3) {
      if (colorSchemeSeed != null) {
        colorScheme = ColorScheme.fromSeed(seedColor: colorSchemeSeed, brightness: effectiveBrightness);
      }
      colorScheme ??= isDark ? _colorSchemeDarkM3 : _colorSchemeLightM3;
407 408 409 410 411 412

      // For surfaces that use primary color in light themes and surface color in dark
      final Color primarySurfaceColor = isDark ? colorScheme.surface : colorScheme.primary;
      final Color onPrimarySurfaceColor = isDark ? colorScheme.onSurface : colorScheme.onPrimary;

      // Default some of the color settings to values from the color scheme
413
      primaryColor ??= primarySurfaceColor;
414 415 416 417 418 419 420 421 422
      canvasColor ??= colorScheme.background;
      scaffoldBackgroundColor ??= colorScheme.background;
      bottomAppBarColor ??= colorScheme.surface;
      cardColor ??= colorScheme.surface;
      dividerColor ??= colorScheme.outline;
      backgroundColor ??= colorScheme.background;
      dialogBackgroundColor ??= colorScheme.background;
      indicatorColor ??= onPrimarySurfaceColor;
      errorColor ??= colorScheme.error;
423
      applyElevationOverlayColor ??= brightness == Brightness.dark;
424 425
    }
    applyElevationOverlayColor ??= false;
426
    primarySwatch ??= Colors.blue;
427
    primaryColor ??= isDark ? Colors.grey[900]! : primarySwatch;
428
    final Brightness estimatedPrimaryColorBrightness = estimateBrightnessForColor(primaryColor);
429 430
    primaryColorLight ??= isDark ? Colors.grey[500]! : primarySwatch[100]!;
    primaryColorDark ??= isDark ? Colors.black : primarySwatch[700]!;
431
    final bool primaryIsDark = estimatedPrimaryColorBrightness == Brightness.dark;
432
    toggleableActiveColor ??= isDark ? Colors.tealAccent[200]! : (colorScheme?.secondary ?? primarySwatch[600]!);
433 434
    focusColor ??= isDark ? Colors.white.withOpacity(0.12) : Colors.black.withOpacity(0.12);
    hoverColor ??= isDark ? Colors.white.withOpacity(0.04) : Colors.black.withOpacity(0.04);
435
    shadowColor ??= Colors.black;
436
    canvasColor ??= isDark ? Colors.grey[850]! : Colors.grey[50]!;
437
    scaffoldBackgroundColor ??= canvasColor;
438
    cardColor ??= isDark ? Colors.grey[800]! : Colors.white;
439
    dividerColor ??= isDark ? const Color(0x1FFFFFFF) : const Color(0x1F000000);
440 441 442 443
    // Create a ColorScheme that is backwards compatible as possible
    // with the existing default ThemeData color values.
    colorScheme ??= ColorScheme.fromSwatch(
      primarySwatch: primarySwatch,
444
      accentColor: isDark ? Colors.tealAccent[200]! : primarySwatch[500]!,
445
      cardColor: cardColor,
446 447
      backgroundColor: isDark ? Colors.grey[700]! : primarySwatch[200]!,
      errorColor: Colors.red[700],
448
      brightness: effectiveBrightness,
449
    );
450
    selectedRowColor ??= Colors.grey[100]!;
451
    unselectedWidgetColor ??= isDark ? Colors.white70 : Colors.black54;
452
    // Spec doesn't specify a dark theme secondaryHeaderColor, this is a guess.
453 454
    secondaryHeaderColor ??= isDark ? Colors.grey[700]! : primarySwatch[50]!;
    dialogBackgroundColor ??= isDark ? Colors.grey[800]! : Colors.white;
455
    indicatorColor ??= colorScheme.secondary == primaryColor ? Colors.white : colorScheme.secondary;
456
    hintColor ??= isDark ? Colors.white60 : Colors.black.withOpacity(0.6);
457 458
    // The default [buttonTheme] is here because it doesn't use the defaults for
    // [disabledColor], [highlightColor], and [splashColor].
459 460
    buttonTheme ??= ButtonThemeData(
      colorScheme: colorScheme,
461
      buttonColor: isDark ? primarySwatch[600]! : Colors.grey[300]!,
462
      disabledColor: disabledColor,
463 464
      focusColor: focusColor,
      hoverColor: hoverColor,
465 466
      highlightColor: highlightColor,
      splashColor: splashColor,
467 468
      materialTapTargetSize: materialTapTargetSize,
    );
469 470 471 472
    disabledColor ??= isDark ? Colors.white38 : Colors.black38;
    highlightColor ??= isDark ? _kDarkThemeHighlightColor : _kLightThemeHighlightColor;
    splashColor ??= isDark ? _kDarkThemeSplashColor : _kLightThemeSplashColor;

473
    // TYPOGRAPHY & ICONOGRAPHY
474 475 476
    typography ??= useMaterial3
      ? Typography.material2021(platform: platform, colorScheme: colorScheme)
      : Typography.material2014(platform: platform);
477 478 479 480 481 482
    TextTheme defaultTextTheme = isDark ? typography.white : typography.black;
    TextTheme defaultPrimaryTextTheme = primaryIsDark ? typography.white : typography.black;
    if (fontFamily != null) {
      defaultTextTheme = defaultTextTheme.apply(fontFamily: fontFamily);
      defaultPrimaryTextTheme = defaultPrimaryTextTheme.apply(fontFamily: fontFamily);
    }
483 484 485 486 487 488 489 490
    if (fontFamilyFallback != null) {
      defaultTextTheme = defaultTextTheme.apply(fontFamilyFallback: fontFamilyFallback);
      defaultPrimaryTextTheme = defaultPrimaryTextTheme.apply(fontFamilyFallback: fontFamilyFallback);
    }
    if (package != null) {
      defaultTextTheme = defaultTextTheme.apply(package: package);
      defaultPrimaryTextTheme = defaultPrimaryTextTheme.apply(package: package);
    }
491 492
    textTheme = defaultTextTheme.merge(textTheme);
    primaryTextTheme = defaultPrimaryTextTheme.merge(primaryTextTheme);
493
    iconTheme ??= isDark ? IconThemeData(color: kDefaultIconLightColor) : IconThemeData(color: kDefaultIconDarkColor);
494 495 496
    primaryIconTheme ??= primaryIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black);

    // COMPONENT THEMES
497
    appBarTheme ??= const AppBarTheme();
498
    badgeTheme ??= const BadgeThemeData();
499
    bannerTheme ??= const MaterialBannerThemeData();
500
    bottomAppBarTheme ??= const BottomAppBarTheme();
501 502 503
    bottomNavigationBarTheme ??= const BottomNavigationBarThemeData();
    bottomSheetTheme ??= const BottomSheetThemeData();
    buttonBarTheme ??= const ButtonBarThemeData();
504
    cardTheme ??= const CardTheme();
505
    checkboxTheme ??= const CheckboxThemeData();
506
    chipTheme ??= const ChipThemeData();
507
    dataTableTheme ??= const DataTableThemeData();
508
    datePickerTheme ??= const DatePickerThemeData();
509
    dialogTheme ??= const DialogTheme();
510 511
    dividerTheme ??= const DividerThemeData();
    drawerTheme ??= const DrawerThemeData();
512
    dropdownMenuTheme ??= const DropdownMenuThemeData();
513
    elevatedButtonTheme ??= const ElevatedButtonThemeData();
514
    expansionTileTheme ??= const ExpansionTileThemeData();
515
    filledButtonTheme ??= const FilledButtonThemeData();
516
    floatingActionButtonTheme ??= const FloatingActionButtonThemeData();
517
    iconButtonTheme ??= const IconButtonThemeData();
518
    listTileTheme ??= const ListTileThemeData();
519 520 521
    menuBarTheme ??= const MenuBarThemeData();
    menuButtonTheme ??= const MenuButtonThemeData();
    menuTheme ??= const MenuThemeData();
522
    navigationBarTheme ??= const NavigationBarThemeData();
hangyu's avatar
hangyu committed
523
    navigationDrawerTheme ??= const NavigationDrawerThemeData();
524
    navigationRailTheme ??= const NavigationRailThemeData();
525
    outlinedButtonTheme ??= const OutlinedButtonThemeData();
526 527
    popupMenuTheme ??= const PopupMenuThemeData();
    progressIndicatorTheme ??= const ProgressIndicatorThemeData();
528
    radioTheme ??= const RadioThemeData();
529
    searchBarTheme ??= const SearchBarThemeData();
530
    searchViewTheme ??= const SearchViewThemeData();
531
    segmentedButtonTheme ??= const SegmentedButtonThemeData();
532 533
    sliderTheme ??= const SliderThemeData();
    snackBarTheme ??= const SnackBarThemeData();
534
    switchTheme ??= const SwitchThemeData();
535 536 537 538 539 540
    tabBarTheme ??= const TabBarTheme();
    textButtonTheme ??= const TextButtonThemeData();
    textSelectionTheme ??= const TextSelectionThemeData();
    timePickerTheme ??= const TimePickerThemeData();
    toggleButtonsTheme ??= const ToggleButtonsThemeData();
    tooltipTheme ??= const TooltipThemeData();
541

542 543 544
    // DEPRECATED (newest deprecations at the bottom)
    errorColor ??= Colors.red[700]!;
    backgroundColor ??= isDark ? Colors.grey[700]! : primarySwatch[200]!;
545
    bottomAppBarColor ??= colorSchemeSeed != null ? colorScheme.surface : isDark ? Colors.grey[800]! : Colors.white;
546

547
    return ThemeData.raw(
548 549 550 551 552
      // 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.

553 554 555
      // GENERAL CONFIGURATION
      applyElevationOverlayColor: applyElevationOverlayColor,
      cupertinoOverrideTheme: cupertinoOverrideTheme,
556
      extensions: _themeExtensionIterableToMap(extensions),
557 558 559 560 561 562
      inputDecorationTheme: inputDecorationTheme,
      materialTapTargetSize: materialTapTargetSize,
      pageTransitionsTheme: pageTransitionsTheme,
      platform: platform,
      scrollbarTheme: scrollbarTheme,
      splashFactory: splashFactory,
563
      useMaterial3: useMaterial3,
564
      visualDensity: visualDensity,
565
      // COLOR
566
      canvasColor: canvasColor,
567
      cardColor: cardColor,
568 569 570
      colorScheme: colorScheme,
      dialogBackgroundColor: dialogBackgroundColor,
      disabledColor: disabledColor,
571
      dividerColor: dividerColor,
572
      focusColor: focusColor,
573 574
      highlightColor: highlightColor,
      hintColor: hintColor,
575 576 577 578 579 580 581 582 583 584
      hoverColor: hoverColor,
      indicatorColor: indicatorColor,
      primaryColor: primaryColor,
      primaryColorDark: primaryColorDark,
      primaryColorLight: primaryColorLight,
      scaffoldBackgroundColor: scaffoldBackgroundColor,
      secondaryHeaderColor: secondaryHeaderColor,
      shadowColor: shadowColor,
      splashColor: splashColor,
      unselectedWidgetColor: unselectedWidgetColor,
585
      // TYPOGRAPHY & ICONOGRAPHY
Ian Hickson's avatar
Ian Hickson committed
586
      iconTheme: iconTheme,
587 588 589
      primaryTextTheme: primaryTextTheme,
      textTheme: textTheme,
      typography: typography,
590
      primaryIconTheme: primaryIconTheme,
591
      // COMPONENT THEMES
592
      actionIconTheme: actionIconTheme,
593
      appBarTheme: appBarTheme,
594
      badgeTheme: badgeTheme,
595
      bannerTheme: bannerTheme,
596
      bottomAppBarTheme: bottomAppBarTheme,
597 598 599 600 601 602 603 604
      bottomNavigationBarTheme: bottomNavigationBarTheme,
      bottomSheetTheme: bottomSheetTheme,
      buttonBarTheme: buttonBarTheme,
      buttonTheme: buttonTheme,
      cardTheme: cardTheme,
      checkboxTheme: checkboxTheme,
      chipTheme: chipTheme,
      dataTableTheme: dataTableTheme,
605
      datePickerTheme: datePickerTheme,
606
      dialogTheme: dialogTheme,
607 608
      dividerTheme: dividerTheme,
      drawerTheme: drawerTheme,
609
      dropdownMenuTheme: dropdownMenuTheme,
610
      elevatedButtonTheme: elevatedButtonTheme,
611
      expansionTileTheme: expansionTileTheme,
612
      filledButtonTheme: filledButtonTheme,
613
      floatingActionButtonTheme: floatingActionButtonTheme,
614
      iconButtonTheme: iconButtonTheme,
615
      listTileTheme: listTileTheme,
616 617 618
      menuBarTheme: menuBarTheme,
      menuButtonTheme: menuButtonTheme,
      menuTheme: menuTheme,
619
      navigationBarTheme: navigationBarTheme,
hangyu's avatar
hangyu committed
620
      navigationDrawerTheme: navigationDrawerTheme,
621
      navigationRailTheme: navigationRailTheme,
622
      outlinedButtonTheme: outlinedButtonTheme,
623 624
      popupMenuTheme: popupMenuTheme,
      progressIndicatorTheme: progressIndicatorTheme,
625
      radioTheme: radioTheme,
626
      searchBarTheme: searchBarTheme,
627
      searchViewTheme: searchViewTheme,
628
      segmentedButtonTheme: segmentedButtonTheme,
629 630
      sliderTheme: sliderTheme,
      snackBarTheme: snackBarTheme,
631
      switchTheme: switchTheme,
632 633 634 635 636 637 638
      tabBarTheme: tabBarTheme,
      textButtonTheme: textButtonTheme,
      textSelectionTheme: textSelectionTheme,
      timePickerTheme: timePickerTheme,
      toggleButtonsTheme: toggleButtonsTheme,
      tooltipTheme: tooltipTheme,
      // DEPRECATED (newest deprecations at the bottom)
639
      androidOverscrollIndicator: androidOverscrollIndicator,
640
      toggleableActiveColor: toggleableActiveColor,
641
      selectedRowColor: selectedRowColor,
642 643
      errorColor: errorColor,
      backgroundColor: backgroundColor,
644
      bottomAppBarColor: bottomAppBarColor,
645
    );
646 647
  }

648
  /// Create a [ThemeData] given a set of exact values. Most values must be
xster's avatar
xster committed
649
  /// specified. They all must also be non-null except for
650
  /// [cupertinoOverrideTheme], and deprecated members.
651 652 653
  ///
  /// This will rarely be used directly. It is used by [lerp] to
  /// create intermediate themes based on two themes created with the
654
  /// [ThemeData] constructor.
655
  const ThemeData.raw({
656 657 658 659 660
    // 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.

661 662 663
    // GENERAL CONFIGURATION
    required this.applyElevationOverlayColor,
    required this.cupertinoOverrideTheme,
664
    required this.extensions,
665 666 667 668 669 670
    required this.inputDecorationTheme,
    required this.materialTapTargetSize,
    required this.pageTransitionsTheme,
    required this.platform,
    required this.scrollbarTheme,
    required this.splashFactory,
671
    required this.useMaterial3,
672
    required this.visualDensity,
673 674 675 676
    // 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.
677
    required this.canvasColor,
678
    required this.cardColor,
679 680 681
    required this.colorScheme,
    required this.dialogBackgroundColor,
    required this.disabledColor,
682
    required this.dividerColor,
683
    required this.focusColor,
684
    required this.highlightColor,
685
    required this.hintColor,
686 687 688 689 690 691 692 693 694 695
    required this.hoverColor,
    required this.indicatorColor,
    required this.primaryColor,
    required this.primaryColorDark,
    required this.primaryColorLight,
    required this.scaffoldBackgroundColor,
    required this.secondaryHeaderColor,
    required this.shadowColor,
    required this.splashColor,
    required this.unselectedWidgetColor,
696 697 698
    // TYPOGRAPHY & ICONOGRAPHY
    required this.iconTheme,
    required this.primaryIconTheme,
699 700 701
    required this.primaryTextTheme,
    required this.textTheme,
    required this.typography,
702
    // COMPONENT THEMES
703
    required this.actionIconTheme,
704
    required this.appBarTheme,
705
    required this.badgeTheme,
706 707 708 709 710
    required this.bannerTheme,
    required this.bottomAppBarTheme,
    required this.bottomNavigationBarTheme,
    required this.bottomSheetTheme,
    required this.buttonBarTheme,
711
    required this.buttonTheme,
712 713 714 715
    required this.cardTheme,
    required this.checkboxTheme,
    required this.chipTheme,
    required this.dataTableTheme,
716
    required this.datePickerTheme,
717 718 719
    required this.dialogTheme,
    required this.dividerTheme,
    required this.drawerTheme,
720
    required this.dropdownMenuTheme,
721
    required this.elevatedButtonTheme,
722
    required this.expansionTileTheme,
723
    required this.filledButtonTheme,
724
    required this.floatingActionButtonTheme,
725
    required this.iconButtonTheme,
726
    required this.listTileTheme,
727 728 729
    required this.menuBarTheme,
    required this.menuButtonTheme,
    required this.menuTheme,
730
    required this.navigationBarTheme,
hangyu's avatar
hangyu committed
731
    required this.navigationDrawerTheme,
732 733 734 735 736
    required this.navigationRailTheme,
    required this.outlinedButtonTheme,
    required this.popupMenuTheme,
    required this.progressIndicatorTheme,
    required this.radioTheme,
737
    required this.searchBarTheme,
738
    required this.searchViewTheme,
739
    required this.segmentedButtonTheme,
740 741 742 743 744 745 746 747 748 749
    required this.sliderTheme,
    required this.snackBarTheme,
    required this.switchTheme,
    required this.tabBarTheme,
    required this.textButtonTheme,
    required this.textSelectionTheme,
    required this.timePickerTheme,
    required this.toggleButtonsTheme,
    required this.tooltipTheme,
    // DEPRECATED (newest deprecations at the bottom)
750 751 752 753
    @Deprecated(
      'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
      'This feature was deprecated after v2.13.0-0.0.pre.'
    )
754
    this.androidOverscrollIndicator,
755 756 757 758
    @Deprecated(
      'No longer used by the framework, please remove any reference to it. '
      'For more information, consult the migration guide at '
      'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
759
      'This feature was deprecated after v3.4.0-19.0.pre.',
760 761
    )
    Color? toggleableActiveColor,
762 763 764 765 766
    @Deprecated(
      'No longer used by the framework, please remove any reference to it. '
      'This feature was deprecated after v3.1.0-0.0.pre.',
    )
    Color? selectedRowColor,
767 768 769 770 771 772 773 774 775 776
    @Deprecated(
      'Use colorScheme.error instead. '
      'This feature was deprecated after v3.3.0-0.5.pre.',
    )
    Color? errorColor,
    @Deprecated(
      'Use colorScheme.background instead. '
      'This feature was deprecated after v3.3.0-0.5.pre.',
    )
    Color? backgroundColor,
777 778 779 780 781 782
    @Deprecated(
      'Use BottomAppBarTheme.color instead. '
      'This feature was deprecated after v3.3.0-0.6.pre.',
    )
    Color? bottomAppBarColor,

783 784
  }) : // DEPRECATED (newest deprecations at the bottom)
       // should not be `required`, use getter pattern to avoid breakages.
785
       _toggleableActiveColor = toggleableActiveColor,
786
       _selectedRowColor = selectedRowColor,
787 788
       _errorColor = errorColor,
       _backgroundColor = backgroundColor,
789
       _bottomAppBarColor = bottomAppBarColor,
790
       assert(toggleableActiveColor != null),
791 792 793
        // DEPRECATED (newest deprecations at the bottom)
       assert(errorColor != null),
       assert(backgroundColor != null);
794

795 796 797 798 799
  /// Create a [ThemeData] based on the colors in the given [colorScheme] and
  /// text styles of the optional [textTheme].
  ///
  /// The [colorScheme] can not be null.
  ///
800
  /// If [colorScheme].brightness is [Brightness.dark] then
801
  /// [ThemeData.applyElevationOverlayColor] will be set to true to support
802 803
  /// the Material dark theme method for indicating elevation by applying
  /// a semi-transparent onSurface color on top of the surface color.
804 805 806 807 808
  ///
  /// This is the recommended method to theme your application. As we move
  /// forward we will be converting all the widget implementations to only use
  /// colors or colors derived from those in [ColorScheme].
  ///
809
  /// {@tool snippet}
810 811 812 813 814
  /// This example will set up an application to use the baseline Material
  /// Design light and dark themes.
  ///
  /// ```dart
  /// MaterialApp(
815 816
  ///   theme: ThemeData.from(colorScheme: const ColorScheme.light()),
  ///   darkTheme: ThemeData.from(colorScheme: const ColorScheme.dark()),
817 818 819 820 821 822 823
  /// )
  /// ```
  /// {@end-tool}
  ///
  /// See <https://material.io/design/color/> for
  /// more discussion on how to pick the right colors.
  factory ThemeData.from({
824 825
    required ColorScheme colorScheme,
    TextTheme? textTheme,
826
    bool? useMaterial3,
827 828 829 830 831 832 833 834
  }) {
    final bool isDark = colorScheme.brightness == Brightness.dark;

    // For surfaces that use primary color in light themes and surface color in dark
    final Color primarySurfaceColor = isDark ? colorScheme.surface : colorScheme.primary;
    final Color onPrimarySurfaceColor = isDark ? colorScheme.onSurface : colorScheme.onPrimary;

    return ThemeData(
835
      colorScheme: colorScheme,
836 837 838 839
      brightness: colorScheme.brightness,
      primaryColor: primarySurfaceColor,
      canvasColor: colorScheme.background,
      scaffoldBackgroundColor: colorScheme.background,
840
      bottomAppBarColor: colorScheme.surface,
841 842 843 844
      cardColor: colorScheme.surface,
      dividerColor: colorScheme.onSurface.withOpacity(0.12),
      backgroundColor: colorScheme.background,
      dialogBackgroundColor: colorScheme.background,
845
      indicatorColor: onPrimarySurfaceColor,
846 847 848
      errorColor: colorScheme.error,
      textTheme: textTheme,
      applyElevationOverlayColor: isDark,
849
      useMaterial3: useMaterial3,
850 851
    );
  }
Ian Hickson's avatar
Ian Hickson committed
852

853
  /// A default light blue theme.
854 855 856
  ///
  /// This theme does not contain text geometry. Instead, it is expected that
  /// this theme is localized using text geometry using [ThemeData.localize].
857 858 859 860
  factory ThemeData.light({bool? useMaterial3}) => ThemeData(
    brightness: Brightness.light,
    useMaterial3: useMaterial3,
  );
861

862
  /// A default dark theme with a teal secondary [ColorScheme] color.
863 864 865
  ///
  /// This theme does not contain text geometry. Instead, it is expected that
  /// this theme is localized using text geometry using [ThemeData.localize].
866 867 868 869
  factory ThemeData.dark({bool? useMaterial3}) => ThemeData(
    brightness: Brightness.dark,
    useMaterial3: useMaterial3,
  );
870

871
  /// The default color theme. Same as [ThemeData.light].
872 873
  ///
  /// This is used by [Theme.of] when no theme has been specified.
874 875 876 877 878 879
  ///
  /// This theme does not contain text geometry. Instead, it is expected that
  /// this theme is localized using text geometry using [ThemeData.localize].
  ///
  /// Most applications would use [Theme.of], which provides correct localized
  /// text geometry.
880
  factory ThemeData.fallback({bool? useMaterial3}) => ThemeData.light(useMaterial3: useMaterial3);
881

882
  /// The overall theme brightness.
883
  ///
884 885 886 887
  /// The default [TextStyle] color for the [textTheme] is black if the
  /// theme is constructed with [Brightness.light] and white if the
  /// theme is constructed with [Brightness.dark].
  Brightness get brightness => colorScheme.brightness;
888

889 890 891 892
  // 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.
893 894 895 896 897 898

  // GENERAL CONFIGURATION

  /// Apply a semi-transparent overlay color on Material surfaces to indicate
  /// elevation for dark themes.
  ///
899 900 901 902 903
  /// If [useMaterial3] is true, then this flag is ignored as there is a new
  /// [Material.surfaceTintColor] used to create an overlay for Material 3.
  /// This flag is meant only for the Material 2 elevation overlay for dark
  /// themes.
  ///
904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944
  /// Material drop shadows can be difficult to see in a dark theme, so the
  /// elevation of a surface should be portrayed with an "overlay" in addition
  /// to the shadow. As the elevation of the component increases, the
  /// overlay increases in opacity. [applyElevationOverlayColor] turns the
  /// application of this overlay on or off for dark themes.
  ///
  /// If true and [brightness] is [Brightness.dark], a
  /// semi-transparent version of [ColorScheme.onSurface] will be
  /// applied on top of [Material] widgets that have a [ColorScheme.surface]
  /// color. The level of transparency is based on [Material.elevation] as
  /// per the Material Dark theme specification.
  ///
  /// If false the surface color will be used unmodified.
  ///
  /// Defaults to false in order to maintain backwards compatibility with
  /// apps that were built before the Material Dark theme specification
  /// was published. New apps should set this to true for any themes
  /// where [brightness] is [Brightness.dark].
  ///
  /// See also:
  ///
  ///  * [Material.elevation], which effects the level of transparency of the
  ///    overlay color.
  ///  * [ElevationOverlay.applyOverlay], which is used by [Material] to apply
  ///    the overlay color to its surface color.
  ///  * <https://material.io/design/color/dark-theme.html>, which specifies how
  ///    the overlay should be applied.
  final bool applyElevationOverlayColor;

  /// Components of the [CupertinoThemeData] to override from the Material
  /// [ThemeData] adaptation.
  ///
  /// By default, [cupertinoOverrideTheme] is null and Cupertino widgets
  /// descendant to the Material [Theme] will adhere to a [CupertinoTheme]
  /// derived from the Material [ThemeData]. e.g. [ThemeData]'s [ColorScheme]
  /// will also inform the [CupertinoThemeData]'s `primaryColor` etc.
  ///
  /// This cascading effect for individual attributes of the [CupertinoThemeData]
  /// can be overridden using attributes of this [cupertinoOverrideTheme].
  final NoDefaultCupertinoThemeData? cupertinoOverrideTheme;

945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
  /// Arbitrary additions to this theme.
  ///
  /// To define extensions, pass an [Iterable] containing one or more [ThemeExtension]
  /// subclasses to [ThemeData.new] or [copyWith].
  ///
  /// To obtain an extension, use [extension].
  ///
  /// {@tool dartpad}
  /// This sample shows how to create and use a subclass of [ThemeExtension] that
  /// defines two colors.
  ///
  /// ** See code in examples/api/lib/material/theme/theme_extension.1.dart **
  /// {@end-tool}
  ///
  /// See also:
  ///
  /// * [extension], a convenience function for obtaining a specific extension.
  final Map<Object, ThemeExtension<dynamic>> extensions;

  /// Used to obtain a particular [ThemeExtension] from [extensions].
  ///
  /// Obtain with `Theme.of(context).extension<MyThemeExtension>()`.
  ///
  /// See [extensions] for an interactive example.
969
  T? extension<T>() => extensions[T] as T?;
970

971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
  /// The default [InputDecoration] values for [InputDecorator], [TextField],
  /// and [TextFormField] are based on this theme.
  ///
  /// See [InputDecoration.applyDefaults].
  final InputDecorationTheme inputDecorationTheme;

  /// Configures the hit test size of certain Material widgets.
  ///
  /// Defaults to a [platform]-appropriate size: [MaterialTapTargetSize.padded]
  /// on mobile platforms, [MaterialTapTargetSize.shrinkWrap] on desktop
  /// platforms.
  final MaterialTapTargetSize materialTapTargetSize;

  /// Default [MaterialPageRoute] transitions per [TargetPlatform].
  ///
  /// [MaterialPageRoute.buildTransitions] delegates to a [platform] specific
  /// [PageTransitionsBuilder]. If a matching builder is not found, a builder
  /// whose platform is null is used.
  final PageTransitionsTheme pageTransitionsTheme;

  /// The platform the material widgets should adapt to target.
  ///
  /// Defaults to the current platform, as exposed by [defaultTargetPlatform].
  /// This should be used in order to style UI elements according to platform
  /// conventions.
  ///
  /// Widgets from the material library should use this getter (via [Theme.of])
  /// to determine the current platform for the purpose of emulating the
  /// platform behavior (e.g. scrolling or haptic effects). Widgets and render
  /// objects at lower layers that try to emulate the underlying platform
1001
  /// can depend on [defaultTargetPlatform] directly, or may require
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028
  /// that the target platform be provided as an argument. The
  /// [dart:io.Platform] object should only be used directly when it's critical
  /// to actually know the current platform, without any overrides possible (for
  /// example, when a system API is about to be called).
  ///
  /// In a test environment, the platform returned is [TargetPlatform.android]
  /// regardless of the host platform. (Android was chosen because the tests
  /// were originally written assuming Android-like behavior, and we added
  /// platform adaptations for other platforms later). Tests can check behavior
  /// for other platforms by setting the [platform] of the [Theme] explicitly to
  /// another [TargetPlatform] value, or by setting
  /// [debugDefaultTargetPlatformOverride].
  ///
  /// Determines the defaults for [typography] and [materialTapTargetSize].
  final TargetPlatform platform;

  /// A theme for customizing the colors, thickness, and shape of [Scrollbar]s.
  final ScrollbarThemeData scrollbarTheme;

  /// Defines the appearance of ink splashes produces by [InkWell]
  /// and [InkResponse].
  ///
  /// See also:
  ///
  ///  * [InkSplash.splashFactory], which defines the default splash.
  ///  * [InkRipple.splashFactory], which defines a splash that spreads out
  ///    more aggressively than the default.
1029 1030
  ///  * [InkSparkle.splashFactory], which defines a more aggressive and organic
  ///    splash with sparkle effects.
1031 1032
  final InteractiveInkFeatureFactory splashFactory;

1033
  /// A temporary flag that can be used to opt-out of Material 3 features.
1034
  ///
1035 1036 1037
  /// This flag is _true_ by default. If false, then components will
  /// continue to use the colors, typography and other features of
  /// Material 2.
1038
  ///
1039 1040 1041 1042
  /// In the long run this flag will be deprecated and eventually
  /// only Material 3 will be supported. We recommend that applications
  /// migrate to Material 3 as soon as that's practical. Until that migration
  /// is complete, this flag can be set to false.
1043 1044
  ///
  /// ## Defaults
1045 1046 1047 1048 1049
  ///
  /// If a [ThemeData] is _constructed_ with [useMaterial3] set to true, then
  /// some properties will get updated defaults. However, the
  /// [ThemeData.copyWith] method with [useMaterial3] set to true will _not_
  /// change any of these properties in the resulting [ThemeData].
1050
  ///
1051 1052
  /// <style>table,td,th { border-collapse: collapse; padding: 0.45em; } td { border: 1px solid }</style>
  ///
1053 1054 1055 1056 1057
  /// | Property        | Material 3 default             | Material 2 default             |
  /// | :-------------- | :----------------------------- | :----------------------------- |
  /// | [colorScheme]   | M3 baseline light color scheme | M2 baseline light color scheme |
  /// | [typography]    | [Typography.material2021]      | [Typography.material2014]      |
  /// | [splashFactory] | [InkSparkle]* or [InkRipple]   | [InkSplash]                    |
1058
  ///
1059
  /// \* if the target platform is Android and the app is not
1060
  /// running on the web, otherwise it will fallback to [InkRipple].
1061
  ///
1062 1063 1064 1065
  /// If [brightness] is [Brightness.dark] then the default color scheme will
  /// be either the M3 baseline dark color scheme or the M2 baseline dark color
  /// scheme depending on [useMaterial3].
  ///
1066 1067 1068 1069 1070
  /// ## Affected widgets
  ///
  /// This flag affects styles and components.
  ///
  /// ### Styles
1071
  ///   * Color: [ColorScheme], [Material] (see table above)
1072
  ///   * Shape: (see components below)
1073
  ///   * Typography: [Typography] (see table above)
1074 1075
  ///
  /// ### Components
1076
  ///   * Badges: [Badge]
1077
  ///   * Bottom app bar: [BottomAppBar]
1078
  ///   * Bottom sheets: [BottomSheet]
1079
  ///   * Buttons
1080
  ///     - Common buttons: [ElevatedButton], [FilledButton], [FilledButton.tonal], [OutlinedButton], [TextButton]
1081
  ///     - FAB: [FloatingActionButton], [FloatingActionButton.extended]
1082
  ///     - Icon buttons: [IconButton], [IconButton.filled] (*new*), [IconButton.filledTonal], [IconButton.outlined]
1083
  ///     - Segmented buttons: [SegmentedButton] (replacing [ToggleButtons])
1084
  ///   * Cards: [Card]
1085
  ///   * Checkbox: [Checkbox], [CheckboxListTile]
1086 1087 1088 1089
  ///   * Chips:
  ///     - [ActionChip] (used for Assist and Suggestion chips),
  ///     - [FilterChip], [ChoiceChip] (used for single selection filter chips),
  ///     - [InputChip]
1090
  ///   * Date pickers: [showDatePicker], [showDateRangePicker], [DatePickerDialog], [DateRangePickerDialog], [InputDatePickerFormField]
1091
  ///   * Dialogs: [AlertDialog], [Dialog.fullscreen]
1092
  ///   * Divider: [Divider], [VerticalDivider]
1093
  ///   * Lists: [ListTile]
1094 1095 1096
  ///   * Menus: [MenuAnchor], [DropdownMenu], [MenuBar]
  ///   * Navigation bar: [NavigationBar] (replacing [BottomNavigationBar])
  ///   * Navigation drawer: [NavigationDrawer] (replacing [Drawer])
1097
  ///   * Navigation rail: [NavigationRail]
1098
  ///   * Progress indicators: [CircularProgressIndicator], [LinearProgressIndicator]
1099
  ///   * Radio button: [Radio], [RadioListTile]
1100
  ///   * Search: [SearchBar], [SearchAnchor],
1101
  ///   * Snack bar: [SnackBar]
1102 1103
  ///   * Slider: [Slider], [RangeSlider]
  ///   * Switch: [Switch], [SwitchListTile]
1104
  ///   * Tabs: [TabBar], [TabBar.secondary]
1105
  ///   * TextFields: [TextField] together with its [InputDecoration]
1106
  ///   * Time pickers: [showTimePicker], [TimePickerDialog]
1107
  ///   * Top app bar: [AppBar], [SliverAppBar], [SliverAppBar.medium], [SliverAppBar.large]
1108 1109 1110 1111
  ///
  /// In addition, this flag enables features introduced in Android 12.
  ///   * Stretch overscroll: [MaterialScrollBehavior]
  ///   * Ripple: `splashFactory` (see table above)
1112
  ///
1113 1114
  /// See also:
  ///
1115
  ///   * [Material 3 specification](https://m3.material.io/).
1116 1117
  final bool useMaterial3;

1118
  /// The density value for specifying the compactness of various UI components.
1119
  ///
1120 1121 1122 1123 1124 1125
  /// {@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.
1126
  ///
1127 1128 1129 1130 1131 1132
  /// 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.
1133
  ///
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143
  /// 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).
1144 1145 1146 1147 1148
  ///
  /// In Material Design 3, the [visualDensity] does not override the value of
  /// [IconButton.visualDensity] which defaults to [VisualDensity.standard]
  /// for all platforms. To override the default value of [IconButton.visualDensity],
  /// use [ThemeData.iconButtonTheme] instead.
1149 1150
  /// {@endtemplate}
  final VisualDensity visualDensity;
1151

1152
  // COLOR
1153 1154

  /// The default color of the [BottomAppBar].
1155 1156 1157 1158 1159 1160
    @Deprecated(
      'Use BottomAppBarTheme.color instead. '
      'This feature was deprecated after v3.3.0-0.6.pre.',
    )
  Color get bottomAppBarColor => _bottomAppBarColor!;
  final Color? _bottomAppBarColor;
1161

1162 1163 1164
  /// The default color of [MaterialType.canvas] [Material].
  final Color canvasColor;

1165 1166 1167
  /// The color of [Material] when it is used as a [Card].
  final Color cardColor;

1168
  /// {@macro flutter.material.color_scheme.ColorScheme}
1169
  ///
1170 1171 1172 1173 1174
  /// This property was added much later than the theme's set of highly specific
  /// colors, like [cardColor], [canvasColor] etc. New components can be defined
  /// exclusively in terms of [colorScheme]. Existing components will gradually
  /// migrate to it, to the extent that is possible without significant
  /// backwards compatibility breaks.
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184
  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;

1185
  /// The color of [Divider]s and [PopupMenuDivider]s, also used
1186
  /// between [ListTile]s, between rows in [DataTable]s, and so forth.
1187 1188 1189
  ///
  /// To create an appropriate [BorderSide] that uses this color, consider
  /// [Divider.createBorderSide].
1190
  final Color dividerColor;
1191

1192 1193 1194
  /// The focus color used indicate that a component has the input focus.
  final Color focusColor;

1195 1196
  /// The highlight color used during ink splash animations or to
  /// indicate an item in a menu is selected.
1197
  final Color highlightColor;
1198

1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
  /// 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)
1211
  ///
1212 1213 1214 1215 1216
  /// The theme's [colorScheme] property contains [ColorScheme.primary], as
  /// well as a color that contrasts well with the primary color called
  /// [ColorScheme.onPrimary]. It might be simpler to just configure an app's
  /// visuals in terms of the theme's [colorScheme].
  final Color primaryColor;
1217

1218 1219
  /// A darker version of the [primaryColor].
  final Color primaryColorDark;
1220

1221 1222
  /// A lighter version of the [primaryColor].
  final Color primaryColorLight;
1223

1224 1225 1226
  /// 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;
1227

1228 1229
  /// The color of the header of a [PaginatedDataTable] when there are selected rows.
  // According to the spec for data tables:
1230
  // https://material.io/archive/guidelines/components/data-tables.html#data-tables-tables-within-cards
1231 1232 1233
  // ...this should be the "50-value of secondary app color".
  final Color secondaryHeaderColor;

1234
  /// The color used to highlight selected rows.
1235 1236 1237 1238 1239 1240
  @Deprecated(
    'No longer used by the framework, please remove any reference to it. '
    'This feature was deprecated after v3.1.0-0.0.pre.',
  )
  Color get selectedRowColor => _selectedRowColor!;
  final Color? _selectedRowColor;
1241

1242 1243 1244 1245 1246 1247 1248 1249 1250 1251
  /// The color that the [Material] widget uses to draw elevation shadows.
  ///
  /// Defaults to fully opaque black.
  ///
  /// Shadows can be difficult to see in a dark theme, so the elevation of a
  /// surface should be rendered with an "overlay" in addition to the shadow.
  /// As the elevation of the component increases, the overlay increases in
  /// opacity. The [applyElevationOverlayColor] property turns the elevation
  /// overlay on or off for dark themes.
  final Color shadowColor;
1252

1253 1254 1255 1256 1257
  /// The color of ink splashes.
  ///
  /// See also:
  ///  * [splashFactory], which defines the appearance of the splash.
  final Color splashColor;
1258

1259 1260 1261 1262
  /// The color used for widgets in their inactive (but enabled)
  /// state. For example, an unchecked checkbox. See also [disabledColor].
  final Color unselectedWidgetColor;

1263 1264
  // TYPOGRAPHY & ICONOGRAPHY

1265 1266
  /// An icon theme that contrasts with the card and canvas colors.
  final IconThemeData iconTheme;
1267

1268 1269
  /// An icon theme that contrasts with the primary color.
  final IconThemeData primaryIconTheme;
1270 1271 1272 1273

  /// A text theme that contrasts with the primary color.
  final TextTheme primaryTextTheme;

1274 1275
  /// Text with a color that contrasts with the card and canvas colors.
  final TextTheme textTheme;
Ian Hickson's avatar
Ian Hickson committed
1276

1277 1278 1279 1280
  /// The color and geometry [TextTheme] values used to configure [textTheme].
  ///
  /// Defaults to a [platform]-appropriate typography.
  final Typography typography;
1281

1282
  // COMPONENT THEMES
1283

1284 1285 1286 1287
  /// A theme for customizing icons of [BackButtonIcon], [CloseButtonIcon],
  /// [DrawerButtonIcon], or [EndDrawerButtonIcon].
  final ActionIconThemeData? actionIconTheme;

1288 1289 1290
  /// A theme for customizing the color, elevation, brightness, iconTheme and
  /// textTheme of [AppBar]s.
  final AppBarTheme appBarTheme;
1291

1292 1293 1294
  /// A theme for customizing the color of [Badge]s.
  final BadgeThemeData badgeTheme;

1295 1296
  /// A theme for customizing the color and text style of a [MaterialBanner].
  final MaterialBannerThemeData bannerTheme;
1297

1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310
  /// A theme for customizing the shape, elevation, and color of a [BottomAppBar].
  final BottomAppBarTheme bottomAppBarTheme;

  /// A theme for customizing the appearance and layout of [BottomNavigationBar]
  /// widgets.
  final BottomNavigationBarThemeData bottomNavigationBarTheme;

  /// A theme for customizing the color, elevation, and shape of a bottom sheet.
  final BottomSheetThemeData bottomSheetTheme;

  /// A theme for customizing the appearance and layout of [ButtonBar] widgets.
  final ButtonBarThemeData buttonBarTheme;

1311 1312
  /// Defines the default configuration of button widgets, like [DropdownButton]
  /// and [ButtonBar].
1313
  final ButtonThemeData buttonTheme;
1314

1315 1316 1317 1318 1319
  /// The colors and styles used to render [Card].
  ///
  /// This is the value returned from [CardTheme.of].
  final CardTheme cardTheme;

1320 1321 1322
  /// A theme for customizing the appearance and layout of [Checkbox] widgets.
  final CheckboxThemeData checkboxTheme;

1323
  /// The colors and styles used to render [Chip]s.
1324 1325 1326 1327
  ///
  /// This is the value returned from [ChipTheme.of].
  final ChipThemeData chipTheme;

1328 1329 1330
  /// A theme for customizing the appearance and layout of [DataTable]
  /// widgets.
  final DataTableThemeData dataTableTheme;
1331

1332 1333 1334 1335
  /// A theme for customizing the appearance and layout of [DatePickerDialog]
  /// widgets.
  final DatePickerThemeData datePickerTheme;

1336 1337
  /// A theme for customizing the shape of a dialog.
  final DialogTheme dialogTheme;
1338

1339 1340 1341
  /// A theme for customizing the color, thickness, and indents of [Divider]s,
  /// [VerticalDivider]s, etc.
  final DividerThemeData dividerTheme;
1342

1343 1344
  /// A theme for customizing the appearance and layout of [Drawer] widgets.
  final DrawerThemeData drawerTheme;
1345

1346 1347 1348
  /// A theme for customizing the appearance and layout of [DropdownMenu] widgets.
  final DropdownMenuThemeData dropdownMenuTheme;

1349 1350 1351
  /// A theme for customizing the appearance and internal layout of
  /// [ElevatedButton]s.
  final ElevatedButtonThemeData elevatedButtonTheme;
1352

1353 1354 1355
  /// A theme for customizing the visual properties of [ExpansionTile]s.
  final ExpansionTileThemeData expansionTileTheme;

1356 1357 1358 1359
  /// A theme for customizing the appearance and internal layout of
  /// [FilledButton]s.
  final FilledButtonThemeData filledButtonTheme;

1360 1361 1362 1363
  /// A theme for customizing the shape, elevation, and color of a
  /// [FloatingActionButton].
  final FloatingActionButtonThemeData floatingActionButtonTheme;

1364 1365 1366 1367
  /// A theme for customizing the appearance and internal layout of
  /// [IconButton]s.
  final IconButtonThemeData iconButtonTheme;

1368 1369 1370
  /// A theme for customizing the appearance of [ListTile] widgets.
  final ListTileThemeData listTileTheme;

1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382
  /// A theme for customizing the color, shape, elevation, and other [MenuStyle]
  /// aspects of the menu bar created by the [MenuBar] widget.
  final MenuBarThemeData menuBarTheme;

  /// A theme for customizing the color, shape, elevation, and text style of
  /// cascading menu buttons created by [SubmenuButton] or [MenuItemButton].
  final MenuButtonThemeData menuButtonTheme;

  /// A theme for customizing the color, shape, elevation, and other [MenuStyle]
  /// attributes of menus created by the [SubmenuButton] widget.
  final MenuThemeData menuTheme;

1383 1384 1385 1386
  /// A theme for customizing the background color, text style, and icon themes
  /// of a [NavigationBar].
  final NavigationBarThemeData navigationBarTheme;

hangyu's avatar
hangyu committed
1387 1388 1389 1390
  /// A theme for customizing the background color, text style, and icon themes
  /// of a [NavigationDrawer].
  final NavigationDrawerThemeData navigationDrawerTheme;

1391 1392 1393 1394
  /// A theme for customizing the background color, elevation, text style, and
  /// icon themes of a [NavigationRail].
  final NavigationRailThemeData navigationRailTheme;

1395 1396 1397
  /// A theme for customizing the appearance and internal layout of
  /// [OutlinedButton]s.
  final OutlinedButtonThemeData outlinedButtonTheme;
1398

1399 1400 1401 1402
  /// A theme for customizing the color, shape, elevation, and text style of
  /// popup menus.
  final PopupMenuThemeData popupMenuTheme;

1403 1404
  /// A theme for customizing the appearance and layout of [ProgressIndicator] widgets.
  final ProgressIndicatorThemeData progressIndicatorTheme;
1405

1406 1407
  /// A theme for customizing the appearance and layout of [Radio] widgets.
  final RadioThemeData radioTheme;
1408

1409 1410 1411
  /// A theme for customizing the appearance and layout of [SearchBar] widgets.
  final SearchBarThemeData searchBarTheme;

1412 1413 1414
  /// A theme for customizing the appearance and layout of search views created by [SearchAnchor] widgets.
  final SearchViewThemeData searchViewTheme;

1415 1416 1417
  /// A theme for customizing the appearance and layout of [SegmentedButton] widgets.
  final SegmentedButtonThemeData segmentedButtonTheme;

1418 1419 1420 1421
  /// The colors and shapes used to render [Slider].
  ///
  /// This is the value returned from [SliderTheme.of].
  final SliderThemeData sliderTheme;
1422

1423 1424
  /// A theme for customizing colors, shape, elevation, and behavior of a [SnackBar].
  final SnackBarThemeData snackBarTheme;
1425

1426 1427 1428 1429 1430
  /// A theme for customizing the appearance and layout of [Switch] widgets.
  final SwitchThemeData switchTheme;

  /// A theme for customizing the size, shape, and color of the tab bar indicator.
  final TabBarTheme tabBarTheme;
1431

1432 1433 1434 1435
  /// A theme for customizing the appearance and internal layout of
  /// [TextButton]s.
  final TextButtonThemeData textButtonTheme;

1436 1437
  /// A theme for customizing the appearance and layout of [TextField] widgets.
  final TextSelectionThemeData textSelectionTheme;
1438

1439 1440
  /// A theme for customizing the appearance and layout of time picker widgets.
  final TimePickerThemeData timePickerTheme;
1441

1442 1443
  /// Defines the default configuration of [ToggleButtons] widgets.
  final ToggleButtonsThemeData toggleButtonsTheme;
1444

1445 1446 1447 1448
  /// A theme for customizing the visual properties of [Tooltip]s.
  ///
  /// This is the value returned from [TooltipTheme.of].
  final TooltipThemeData tooltipTheme;
1449

1450
  // DEPRECATED (newest deprecations at the bottom)
1451

1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472
  /// 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;

1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490
  /// Obsolete property that was used for input validation errors, e.g. in
  /// [TextField] fields. Use [ColorScheme.error] instead.
  @Deprecated(
    'Use colorScheme.error instead. '
    'This feature was deprecated after v3.3.0-0.5.pre.',
  )
  Color get errorColor => _errorColor!;
  final Color? _errorColor;

  /// Obsolete property that was unused by the framework.
  /// Use [ColorScheme.background] instead.
  @Deprecated(
    'Use colorScheme.background instead. '
    'This feature was deprecated after v3.3.0-0.5.pre.',
  )
  Color get backgroundColor => _backgroundColor!;
  final Color? _backgroundColor;

1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501
  /// The color used to highlight the active states of toggleable widgets like
  /// [Switch], [Radio], and [Checkbox].
  @Deprecated(
    'No longer used by the framework, please remove any reference to it. '
    'For more information, consult the migration guide at '
    'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
    'This feature was deprecated after v3.4.0-19.0.pre.',
  )
  Color get toggleableActiveColor => _toggleableActiveColor!;
  final Color? _toggleableActiveColor;

1502 1503 1504 1505 1506 1507 1508
  // The number 5 was chosen without any real science or research behind it. It

  // copies of ThemeData in memory comfortably) and not too small (most apps
  // shouldn't have more than 5 theme/localization pairs).
  static const int _localizedThemeDataCacheSize = 5;
  /// Caches localized themes to speed up the [localize] method.

1509
  /// Creates a copy of this theme but with the given fields replaced with the new values.
1510 1511
  ///
  /// The [brightness] value is applied to the [colorScheme].
1512
  ThemeData copyWith({
1513 1514 1515 1516 1517
    // 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.

1518 1519 1520
    // GENERAL CONFIGURATION
    bool? applyElevationOverlayColor,
    NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
1521
    Iterable<ThemeExtension<dynamic>>? extensions,
1522 1523 1524 1525 1526 1527
    InputDecorationTheme? inputDecorationTheme,
    MaterialTapTargetSize? materialTapTargetSize,
    PageTransitionsTheme? pageTransitionsTheme,
    TargetPlatform? platform,
    ScrollbarThemeData? scrollbarTheme,
    InteractiveInkFeatureFactory? splashFactory,
1528
    bool? useMaterial3,
1529
    VisualDensity? visualDensity,
1530 1531 1532 1533 1534 1535
    // 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.
    Brightness? brightness,
    Color? canvasColor,
1536
    Color? cardColor,
1537 1538 1539
    ColorScheme? colorScheme,
    Color? dialogBackgroundColor,
    Color? disabledColor,
1540
    Color? dividerColor,
1541
    Color? focusColor,
1542
    Color? highlightColor,
1543
    Color? hintColor,
1544 1545 1546 1547 1548 1549 1550 1551 1552 1553
    Color? hoverColor,
    Color? indicatorColor,
    Color? primaryColor,
    Color? primaryColorDark,
    Color? primaryColorLight,
    Color? scaffoldBackgroundColor,
    Color? secondaryHeaderColor,
    Color? shadowColor,
    Color? splashColor,
    Color? unselectedWidgetColor,
1554 1555 1556
    // TYPOGRAPHY & ICONOGRAPHY
    IconThemeData? iconTheme,
    IconThemeData? primaryIconTheme,
1557 1558 1559
    TextTheme? primaryTextTheme,
    TextTheme? textTheme,
    Typography? typography,
1560
    // COMPONENT THEMES
1561
    ActionIconThemeData? actionIconTheme,
1562
    AppBarTheme? appBarTheme,
1563
    BadgeThemeData? badgeTheme,
1564 1565 1566 1567 1568
    MaterialBannerThemeData? bannerTheme,
    BottomAppBarTheme? bottomAppBarTheme,
    BottomNavigationBarThemeData? bottomNavigationBarTheme,
    BottomSheetThemeData? bottomSheetTheme,
    ButtonBarThemeData? buttonBarTheme,
1569
    ButtonThemeData? buttonTheme,
1570 1571 1572 1573
    CardTheme? cardTheme,
    CheckboxThemeData? checkboxTheme,
    ChipThemeData? chipTheme,
    DataTableThemeData? dataTableTheme,
1574
    DatePickerThemeData? datePickerTheme,
1575 1576 1577
    DialogTheme? dialogTheme,
    DividerThemeData? dividerTheme,
    DrawerThemeData? drawerTheme,
1578
    DropdownMenuThemeData? dropdownMenuTheme,
1579
    ElevatedButtonThemeData? elevatedButtonTheme,
1580
    ExpansionTileThemeData? expansionTileTheme,
1581
    FilledButtonThemeData? filledButtonTheme,
1582
    FloatingActionButtonThemeData? floatingActionButtonTheme,
1583
    IconButtonThemeData? iconButtonTheme,
1584
    ListTileThemeData? listTileTheme,
1585 1586 1587
    MenuBarThemeData? menuBarTheme,
    MenuButtonThemeData? menuButtonTheme,
    MenuThemeData? menuTheme,
1588
    NavigationBarThemeData? navigationBarTheme,
hangyu's avatar
hangyu committed
1589
    NavigationDrawerThemeData? navigationDrawerTheme,
1590 1591 1592 1593 1594
    NavigationRailThemeData? navigationRailTheme,
    OutlinedButtonThemeData? outlinedButtonTheme,
    PopupMenuThemeData? popupMenuTheme,
    ProgressIndicatorThemeData? progressIndicatorTheme,
    RadioThemeData? radioTheme,
1595
    SearchBarThemeData? searchBarTheme,
1596
    SearchViewThemeData? searchViewTheme,
1597
    SegmentedButtonThemeData? segmentedButtonTheme,
1598 1599 1600 1601 1602 1603 1604
    SliderThemeData? sliderTheme,
    SnackBarThemeData? snackBarTheme,
    SwitchThemeData? switchTheme,
    TabBarTheme? tabBarTheme,
    TextButtonThemeData? textButtonTheme,
    TextSelectionThemeData? textSelectionTheme,
    TimePickerThemeData? timePickerTheme,
1605
    ToggleButtonsThemeData? toggleButtonsTheme,
1606 1607
    TooltipThemeData? tooltipTheme,
    // DEPRECATED (newest deprecations at the bottom)
1608 1609 1610 1611 1612
    @Deprecated(
      'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
      'This feature was deprecated after v2.13.0-0.0.pre.'
    )
    AndroidOverscrollIndicator? androidOverscrollIndicator,
1613 1614 1615 1616
    @Deprecated(
      'No longer used by the framework, please remove any reference to it. '
      'For more information, consult the migration guide at '
      'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
1617
      'This feature was deprecated after v3.4.0-19.0.pre.',
1618 1619
    )
    Color? toggleableActiveColor,
1620 1621 1622 1623 1624
    @Deprecated(
      'No longer used by the framework, please remove any reference to it. '
      'This feature was deprecated after v3.1.0-0.0.pre.',
    )
    Color? selectedRowColor,
1625 1626 1627 1628 1629 1630 1631 1632 1633 1634
    @Deprecated(
      'Use colorScheme.error instead. '
      'This feature was deprecated after v2.6.0-11.0.pre.',
    )
    Color? errorColor,
    @Deprecated(
      'Use colorScheme.background instead. '
      'This feature was deprecated after v2.6.0-11.0.pre.',
    )
    Color? backgroundColor,
1635 1636 1637 1638 1639
    @Deprecated(
      'Use BottomAppBarTheme.color instead. '
      'This feature was deprecated after v3.3.0-0.6.pre.',
    )
    Color? bottomAppBarColor,
1640
  }) {
xster's avatar
xster committed
1641
    cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
1642
    return ThemeData.raw(
1643 1644 1645 1646 1647
      // 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.

1648 1649 1650
      // GENERAL CONFIGURATION
      applyElevationOverlayColor: applyElevationOverlayColor ?? this.applyElevationOverlayColor,
      cupertinoOverrideTheme: cupertinoOverrideTheme ?? this.cupertinoOverrideTheme,
1651
      extensions: (extensions != null) ? _themeExtensionIterableToMap(extensions) : this.extensions,
1652 1653 1654 1655 1656 1657
      inputDecorationTheme: inputDecorationTheme ?? this.inputDecorationTheme,
      materialTapTargetSize: materialTapTargetSize ?? this.materialTapTargetSize,
      pageTransitionsTheme: pageTransitionsTheme ?? this.pageTransitionsTheme,
      platform: platform ?? this.platform,
      scrollbarTheme: scrollbarTheme ?? this.scrollbarTheme,
      splashFactory: splashFactory ?? this.splashFactory,
1658
      useMaterial3: useMaterial3 ?? this.useMaterial3,
1659
      visualDensity: visualDensity ?? this.visualDensity,
1660
      // COLOR
1661
      canvasColor: canvasColor ?? this.canvasColor,
1662
      cardColor: cardColor ?? this.cardColor,
1663 1664 1665
      colorScheme: (colorScheme ?? this.colorScheme).copyWith(brightness: brightness),
      dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor,
      disabledColor: disabledColor ?? this.disabledColor,
1666
      dividerColor: dividerColor ?? this.dividerColor,
1667
      focusColor: focusColor ?? this.focusColor,
1668 1669
      highlightColor: highlightColor ?? this.highlightColor,
      hintColor: hintColor ?? this.hintColor,
1670 1671 1672 1673 1674 1675 1676 1677 1678 1679
      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,
      shadowColor: shadowColor ?? this.shadowColor,
      splashColor: splashColor ?? this.splashColor,
      unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor,
1680
      // TYPOGRAPHY & ICONOGRAPHY
1681 1682
      iconTheme: iconTheme ?? this.iconTheme,
      primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme,
1683 1684 1685
      primaryTextTheme: primaryTextTheme ?? this.primaryTextTheme,
      textTheme: textTheme ?? this.textTheme,
      typography: typography ?? this.typography,
1686
      // COMPONENT THEMES
1687
      actionIconTheme: actionIconTheme ?? this.actionIconTheme,
1688
      appBarTheme: appBarTheme ?? this.appBarTheme,
1689
      badgeTheme: badgeTheme ?? this.badgeTheme,
1690
      bannerTheme: bannerTheme ?? this.bannerTheme,
1691
      bottomAppBarTheme: bottomAppBarTheme ?? this.bottomAppBarTheme,
1692 1693 1694 1695 1696 1697 1698 1699
      bottomNavigationBarTheme: bottomNavigationBarTheme ?? this.bottomNavigationBarTheme,
      bottomSheetTheme: bottomSheetTheme ?? this.bottomSheetTheme,
      buttonBarTheme: buttonBarTheme ?? this.buttonBarTheme,
      buttonTheme: buttonTheme ?? this.buttonTheme,
      cardTheme: cardTheme ?? this.cardTheme,
      checkboxTheme: checkboxTheme ?? this.checkboxTheme,
      chipTheme: chipTheme ?? this.chipTheme,
      dataTableTheme: dataTableTheme ?? this.dataTableTheme,
1700
      datePickerTheme: datePickerTheme ?? this.datePickerTheme,
1701
      dialogTheme: dialogTheme ?? this.dialogTheme,
1702 1703
      dividerTheme: dividerTheme ?? this.dividerTheme,
      drawerTheme: drawerTheme ?? this.drawerTheme,
1704
      dropdownMenuTheme: dropdownMenuTheme ?? this.dropdownMenuTheme,
1705
      elevatedButtonTheme: elevatedButtonTheme ?? this.elevatedButtonTheme,
1706
      expansionTileTheme: expansionTileTheme ?? this.expansionTileTheme,
1707
      filledButtonTheme: filledButtonTheme ?? this.filledButtonTheme,
1708
      floatingActionButtonTheme: floatingActionButtonTheme ?? this.floatingActionButtonTheme,
1709
      iconButtonTheme: iconButtonTheme ?? this.iconButtonTheme,
1710
      listTileTheme: listTileTheme ?? this.listTileTheme,
1711 1712 1713
      menuBarTheme: menuBarTheme ?? this.menuBarTheme,
      menuButtonTheme: menuButtonTheme ?? this.menuButtonTheme,
      menuTheme: menuTheme ?? this.menuTheme,
1714
      navigationBarTheme: navigationBarTheme ?? this.navigationBarTheme,
hangyu's avatar
hangyu committed
1715
      navigationDrawerTheme: navigationDrawerTheme ?? this.navigationDrawerTheme,
1716
      navigationRailTheme: navigationRailTheme ?? this.navigationRailTheme,
1717
      outlinedButtonTheme: outlinedButtonTheme ?? this.outlinedButtonTheme,
1718 1719
      popupMenuTheme: popupMenuTheme ?? this.popupMenuTheme,
      progressIndicatorTheme: progressIndicatorTheme ?? this.progressIndicatorTheme,
1720
      radioTheme: radioTheme ?? this.radioTheme,
1721
      searchBarTheme: searchBarTheme ?? this.searchBarTheme,
1722
      searchViewTheme: searchViewTheme ?? this.searchViewTheme,
1723
      segmentedButtonTheme: segmentedButtonTheme ?? this.segmentedButtonTheme,
1724 1725
      sliderTheme: sliderTheme ?? this.sliderTheme,
      snackBarTheme: snackBarTheme ?? this.snackBarTheme,
1726
      switchTheme: switchTheme ?? this.switchTheme,
1727 1728 1729 1730 1731 1732 1733
      tabBarTheme: tabBarTheme ?? this.tabBarTheme,
      textButtonTheme: textButtonTheme ?? this.textButtonTheme,
      textSelectionTheme: textSelectionTheme ?? this.textSelectionTheme,
      timePickerTheme: timePickerTheme ?? this.timePickerTheme,
      toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
      tooltipTheme: tooltipTheme ?? this.tooltipTheme,
      // DEPRECATED (newest deprecations at the bottom)
1734
      androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator,
1735 1736
      toggleableActiveColor: toggleableActiveColor ?? _toggleableActiveColor,
      selectedRowColor: selectedRowColor ?? _selectedRowColor,
1737 1738
      errorColor: errorColor ?? _errorColor,
      backgroundColor: backgroundColor ?? _backgroundColor,
1739
      bottomAppBarColor: bottomAppBarColor ?? _bottomAppBarColor,
1740 1741
    );
  }
1742
  // just seemed like a number that's not too big (we should be able to fit 5
1743
  static final _FifoCache<_IdentityThemeDataCacheKey, ThemeData> _localizedThemeDataCache =
1744
      _FifoCache<_IdentityThemeDataCacheKey, ThemeData>(_localizedThemeDataCacheSize);
1745

1746 1747
  /// Returns a new theme built by merging the text geometry provided by the
  /// [localTextGeometry] theme with the [baseTheme].
1748
  ///
1749 1750 1751 1752
  /// For those text styles in the [baseTheme] whose [TextStyle.inherit] is set
  /// to true, the returned theme's text styles inherit the geometric properties
  /// of [localTextGeometry]. The resulting text styles' [TextStyle.inherit] is
  /// set to those provided by [localTextGeometry].
1753
  static ThemeData localize(ThemeData baseTheme, TextTheme localTextGeometry) {
1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767
    // WARNING: this method memoizes the result in a cache based on the
    // previously seen baseTheme and localTextGeometry. Memoization is safe
    // because all inputs and outputs of this function are deeply immutable, and
    // the computations are referentially transparent. It only short-circuits
    // the computation if the new inputs are identical() to the previous ones.
    // It does not use the == operator, which performs a costly deep comparison.
    //
    // When changing this method, make sure the memoization logic is correct.
    // Remember:
    //
    // There are only two hard things in Computer Science: cache invalidation
    // and naming things. -- Phil Karlton

    return _localizedThemeDataCache.putIfAbsent(
1768
      _IdentityThemeDataCacheKey(baseTheme, localTextGeometry),
1769 1770 1771 1772 1773 1774 1775
      () {
        return baseTheme.copyWith(
          primaryTextTheme: localTextGeometry.merge(baseTheme.primaryTextTheme),
          textTheme: localTextGeometry.merge(baseTheme.textTheme),
        );
      },
    );
1776 1777
  }

1778 1779 1780 1781
  /// Determines whether the given [Color] is [Brightness.light] or
  /// [Brightness.dark].
  ///
  /// This compares the luminosity of the given color to a threshold value that
1782
  /// matches the Material Design specification.
1783
  static Brightness estimateBrightnessForColor(Color color) {
1784
    final double relativeLuminance = color.computeLuminance();
1785 1786 1787 1788 1789 1790

    // See <https://www.w3.org/TR/WCAG20/#contrast-ratiodef>
    // The spec says to use kThreshold=0.0525, but Material Design appears to bias
    // more towards using light text than WCAG20 recommends. Material Design spec
    // doesn't say what value to use, but 0.15 seemed close to what the Material
    // Design spec shows for its color palette on
1791
    // <https://material.io/go/design-theming#color-color-palette>.
1792
    const double kThreshold = 0.15;
1793
    if ((relativeLuminance + 0.05) * (relativeLuminance + 0.05) > kThreshold) {
1794
      return Brightness.light;
1795
    }
1796 1797 1798
    return Brightness.dark;
  }

1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822
  /// Linearly interpolate between two [extensions].
  ///
  /// Includes all theme extensions in [a] and [b].
  ///
  /// {@macro dart.ui.shadow.lerp}
  static Map<Object, ThemeExtension<dynamic>> _lerpThemeExtensions(ThemeData a, ThemeData b, double t) {
    // Lerp [a].
    final Map<Object, ThemeExtension<dynamic>> newExtensions = a.extensions.map((Object id, ThemeExtension<dynamic> extensionA) {
        final ThemeExtension<dynamic>? extensionB = b.extensions[id];
        return MapEntry<Object, ThemeExtension<dynamic>>(id, extensionA.lerp(extensionB, t));
      });
    // Add [b]-only extensions.
    newExtensions.addEntries(b.extensions.entries.where(
      (MapEntry<Object, ThemeExtension<dynamic>> entry) =>
          !a.extensions.containsKey(entry.key)));

    return newExtensions;
  }

  /// Convert the [extensionsIterable] passed to [ThemeData.new] or [copyWith]
  /// to the stored [extensions] map, where each entry's key consists of the extension's type.
  static Map<Object, ThemeExtension<dynamic>> _themeExtensionIterableToMap(Iterable<ThemeExtension<dynamic>> extensionsIterable) {
    return Map<Object, ThemeExtension<dynamic>>.unmodifiable(<Object, ThemeExtension<dynamic>>{
      // Strangely, the cast is necessary for tests to run.
1823
      for (final ThemeExtension<dynamic> extension in extensionsIterable) extension.type: extension as ThemeExtension<ThemeExtension<dynamic>>,
1824 1825 1826
    });
  }

1827
  /// Linearly interpolate between two themes.
1828
  ///
1829
  /// The arguments must not be null.
1830
  ///
1831
  /// {@macro dart.ui.shadow.lerp}
1832
  static ThemeData lerp(ThemeData a, ThemeData b, double t) {
1833 1834 1835
    if (identical(a, b)) {
      return a;
    }
1836
    return ThemeData.raw(
1837 1838 1839 1840 1841
      // 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.

1842 1843 1844
      // GENERAL CONFIGURATION
      applyElevationOverlayColor:t < 0.5 ? a.applyElevationOverlayColor : b.applyElevationOverlayColor,
      cupertinoOverrideTheme:t < 0.5 ? a.cupertinoOverrideTheme : b.cupertinoOverrideTheme,
1845
      extensions: _lerpThemeExtensions(a, b, t),
1846 1847 1848 1849 1850 1851
      inputDecorationTheme:t < 0.5 ? a.inputDecorationTheme : b.inputDecorationTheme,
      materialTapTargetSize:t < 0.5 ? a.materialTapTargetSize : b.materialTapTargetSize,
      pageTransitionsTheme:t < 0.5 ? a.pageTransitionsTheme : b.pageTransitionsTheme,
      platform: t < 0.5 ? a.platform : b.platform,
      scrollbarTheme: ScrollbarThemeData.lerp(a.scrollbarTheme, b.scrollbarTheme, t),
      splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory,
1852
      useMaterial3: t < 0.5 ? a.useMaterial3 : b.useMaterial3,
1853
      visualDensity: VisualDensity.lerp(a.visualDensity, b.visualDensity, t),
1854
      // COLOR
1855
      canvasColor: Color.lerp(a.canvasColor, b.canvasColor, t)!,
1856
      cardColor: Color.lerp(a.cardColor, b.cardColor, t)!,
1857 1858 1859
      colorScheme: ColorScheme.lerp(a.colorScheme, b.colorScheme, t),
      dialogBackgroundColor: Color.lerp(a.dialogBackgroundColor, b.dialogBackgroundColor, t)!,
      disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t)!,
1860
      dividerColor: Color.lerp(a.dividerColor, b.dividerColor, t)!,
1861
      focusColor: Color.lerp(a.focusColor, b.focusColor, t)!,
1862 1863
      highlightColor: Color.lerp(a.highlightColor, b.highlightColor, t)!,
      hintColor: Color.lerp(a.hintColor, b.hintColor, t)!,
1864 1865 1866 1867 1868 1869 1870 1871 1872 1873
      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)!,
      shadowColor: Color.lerp(a.shadowColor, b.shadowColor, t)!,
      splashColor: Color.lerp(a.splashColor, b.splashColor, t)!,
      unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t)!,
1874
      // TYPOGRAPHY & ICONOGRAPHY
1875 1876
      iconTheme: IconThemeData.lerp(a.iconTheme, b.iconTheme, t),
      primaryIconTheme: IconThemeData.lerp(a.primaryIconTheme, b.primaryIconTheme, t),
1877 1878 1879
      primaryTextTheme: TextTheme.lerp(a.primaryTextTheme, b.primaryTextTheme, t),
      textTheme: TextTheme.lerp(a.textTheme, b.textTheme, t),
      typography: Typography.lerp(a.typography, b.typography, t),
1880
      // COMPONENT THEMES
1881
      actionIconTheme: ActionIconThemeData.lerp(a.actionIconTheme, b.actionIconTheme, t),
1882
      appBarTheme: AppBarTheme.lerp(a.appBarTheme, b.appBarTheme, t),
1883
      badgeTheme: BadgeThemeData.lerp(a.badgeTheme, b.badgeTheme, t),
1884
      bannerTheme: MaterialBannerThemeData.lerp(a.bannerTheme, b.bannerTheme, t),
1885
      bottomAppBarTheme: BottomAppBarTheme.lerp(a.bottomAppBarTheme, b.bottomAppBarTheme, t),
1886 1887 1888 1889 1890 1891 1892 1893
      bottomNavigationBarTheme: BottomNavigationBarThemeData.lerp(a.bottomNavigationBarTheme, b.bottomNavigationBarTheme, t),
      bottomSheetTheme: BottomSheetThemeData.lerp(a.bottomSheetTheme, b.bottomSheetTheme, t)!,
      buttonBarTheme: ButtonBarThemeData.lerp(a.buttonBarTheme, b.buttonBarTheme, t)!,
      buttonTheme: t < 0.5 ? a.buttonTheme : b.buttonTheme,
      cardTheme: CardTheme.lerp(a.cardTheme, b.cardTheme, t),
      checkboxTheme: CheckboxThemeData.lerp(a.checkboxTheme, b.checkboxTheme, t),
      chipTheme: ChipThemeData.lerp(a.chipTheme, b.chipTheme, t)!,
      dataTableTheme: DataTableThemeData.lerp(a.dataTableTheme, b.dataTableTheme, t),
1894
      datePickerTheme: DatePickerThemeData.lerp(a.datePickerTheme, b.datePickerTheme, t),
1895
      dialogTheme: DialogTheme.lerp(a.dialogTheme, b.dialogTheme, t),
1896 1897
      dividerTheme: DividerThemeData.lerp(a.dividerTheme, b.dividerTheme, t),
      drawerTheme: DrawerThemeData.lerp(a.drawerTheme, b.drawerTheme, t)!,
1898
      dropdownMenuTheme: DropdownMenuThemeData.lerp(a.dropdownMenuTheme, b.dropdownMenuTheme, t),
1899
      elevatedButtonTheme: ElevatedButtonThemeData.lerp(a.elevatedButtonTheme, b.elevatedButtonTheme, t)!,
1900
      expansionTileTheme: ExpansionTileThemeData.lerp(a.expansionTileTheme, b.expansionTileTheme, t)!,
1901
      filledButtonTheme: FilledButtonThemeData.lerp(a.filledButtonTheme, b.filledButtonTheme, t)!,
1902
      floatingActionButtonTheme: FloatingActionButtonThemeData.lerp(a.floatingActionButtonTheme, b.floatingActionButtonTheme, t)!,
1903
      iconButtonTheme: IconButtonThemeData.lerp(a.iconButtonTheme, b.iconButtonTheme, t)!,
1904
      listTileTheme: ListTileThemeData.lerp(a.listTileTheme, b.listTileTheme, t)!,
1905 1906 1907
      menuBarTheme: MenuBarThemeData.lerp(a.menuBarTheme, b.menuBarTheme, t)!,
      menuButtonTheme: MenuButtonThemeData.lerp(a.menuButtonTheme, b.menuButtonTheme, t)!,
      menuTheme: MenuThemeData.lerp(a.menuTheme, b.menuTheme, t)!,
1908
      navigationBarTheme: NavigationBarThemeData.lerp(a.navigationBarTheme, b.navigationBarTheme, t)!,
hangyu's avatar
hangyu committed
1909
      navigationDrawerTheme: NavigationDrawerThemeData.lerp(a.navigationDrawerTheme, b.navigationDrawerTheme, t)!,
1910
      navigationRailTheme: NavigationRailThemeData.lerp(a.navigationRailTheme, b.navigationRailTheme, t)!,
1911
      outlinedButtonTheme: OutlinedButtonThemeData.lerp(a.outlinedButtonTheme, b.outlinedButtonTheme, t)!,
1912 1913
      popupMenuTheme: PopupMenuThemeData.lerp(a.popupMenuTheme, b.popupMenuTheme, t)!,
      progressIndicatorTheme: ProgressIndicatorThemeData.lerp(a.progressIndicatorTheme, b.progressIndicatorTheme, t)!,
1914
      radioTheme: RadioThemeData.lerp(a.radioTheme, b.radioTheme, t),
1915
      searchBarTheme: SearchBarThemeData.lerp(a.searchBarTheme, b.searchBarTheme, t)!,
1916
      searchViewTheme: SearchViewThemeData.lerp(a.searchViewTheme, b.searchViewTheme, t)!,
1917
      segmentedButtonTheme: SegmentedButtonThemeData.lerp(a.segmentedButtonTheme, b.segmentedButtonTheme, t),
1918 1919
      sliderTheme: SliderThemeData.lerp(a.sliderTheme, b.sliderTheme, t),
      snackBarTheme: SnackBarThemeData.lerp(a.snackBarTheme, b.snackBarTheme, t),
1920
      switchTheme: SwitchThemeData.lerp(a.switchTheme, b.switchTheme, t),
1921 1922 1923 1924 1925 1926 1927
      tabBarTheme: TabBarTheme.lerp(a.tabBarTheme, b.tabBarTheme, t),
      textButtonTheme: TextButtonThemeData.lerp(a.textButtonTheme, b.textButtonTheme, t)!,
      textSelectionTheme: TextSelectionThemeData.lerp(a.textSelectionTheme, b.textSelectionTheme, t)!,
      timePickerTheme: TimePickerThemeData.lerp(a.timePickerTheme, b.timePickerTheme, t),
      toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t)!,
      tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t)!,
      // DEPRECATED (newest deprecations at the bottom)
1928
      androidOverscrollIndicator:t < 0.5 ? a.androidOverscrollIndicator : b.androidOverscrollIndicator,
1929
      toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t),
1930
      selectedRowColor: Color.lerp(a.selectedRowColor, b.selectedRowColor, t),
1931 1932
      errorColor: Color.lerp(a.errorColor, b.errorColor, t),
      backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t),
1933
      bottomAppBarColor: Color.lerp(a.bottomAppBarColor, b.bottomAppBarColor, t),
1934 1935 1936
    );
  }

1937
  @override
1938
  bool operator ==(Object other) {
1939
    if (other.runtimeType != runtimeType) {
1940
      return false;
1941
    }
1942
    return other is ThemeData &&
1943 1944 1945 1946 1947
        // 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.

1948 1949 1950
        // GENERAL CONFIGURATION
        other.applyElevationOverlayColor == applyElevationOverlayColor &&
        other.cupertinoOverrideTheme == cupertinoOverrideTheme &&
1951
        mapEquals(other.extensions, extensions) &&
1952 1953 1954 1955 1956 1957
        other.inputDecorationTheme == inputDecorationTheme &&
        other.materialTapTargetSize == materialTapTargetSize &&
        other.pageTransitionsTheme == pageTransitionsTheme &&
        other.platform == platform &&
        other.scrollbarTheme == scrollbarTheme &&
        other.splashFactory == splashFactory &&
1958
        other.useMaterial3 == useMaterial3 &&
1959
        other.visualDensity == visualDensity &&
1960
        // COLOR
1961
        other.canvasColor == canvasColor &&
1962
        other.cardColor == cardColor &&
1963 1964 1965
        other.colorScheme == colorScheme &&
        other.dialogBackgroundColor == dialogBackgroundColor &&
        other.disabledColor == disabledColor &&
1966
        other.dividerColor == dividerColor &&
1967
        other.focusColor == focusColor &&
1968 1969
        other.highlightColor == highlightColor &&
        other.hintColor == hintColor &&
1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
        other.hoverColor == hoverColor &&
        other.indicatorColor == indicatorColor &&
        other.primaryColor == primaryColor &&
        other.primaryColorDark == primaryColorDark &&
        other.primaryColorLight == primaryColorLight &&
        other.scaffoldBackgroundColor == scaffoldBackgroundColor &&
        other.secondaryHeaderColor == secondaryHeaderColor &&
        other.shadowColor == shadowColor &&
        other.splashColor == splashColor &&
        other.unselectedWidgetColor == unselectedWidgetColor &&
1980 1981 1982
        // TYPOGRAPHY & ICONOGRAPHY
        other.iconTheme == iconTheme &&
        other.primaryIconTheme == primaryIconTheme &&
1983 1984 1985
        other.primaryTextTheme == primaryTextTheme &&
        other.textTheme == textTheme &&
        other.typography == typography &&
1986
        // COMPONENT THEMES
1987
        other.actionIconTheme == actionIconTheme &&
1988
        other.appBarTheme == appBarTheme &&
1989
        other.badgeTheme == badgeTheme &&
1990 1991 1992 1993 1994 1995 1996 1997 1998 1999
        other.bannerTheme == bannerTheme &&
        other.bottomAppBarTheme == bottomAppBarTheme &&
        other.bottomNavigationBarTheme == bottomNavigationBarTheme &&
        other.bottomSheetTheme == bottomSheetTheme &&
        other.buttonBarTheme == buttonBarTheme &&
        other.buttonTheme == buttonTheme &&
        other.cardTheme == cardTheme &&
        other.checkboxTheme == checkboxTheme &&
        other.chipTheme == chipTheme &&
        other.dataTableTheme == dataTableTheme &&
2000
        other.datePickerTheme == datePickerTheme &&
2001 2002 2003
        other.dialogTheme == dialogTheme &&
        other.dividerTheme == dividerTheme &&
        other.drawerTheme == drawerTheme &&
2004
        other.dropdownMenuTheme == dropdownMenuTheme &&
2005
        other.elevatedButtonTheme == elevatedButtonTheme &&
2006
        other.expansionTileTheme == expansionTileTheme &&
2007
        other.filledButtonTheme == filledButtonTheme &&
2008
        other.floatingActionButtonTheme == floatingActionButtonTheme &&
2009
        other.iconButtonTheme == iconButtonTheme &&
2010
        other.listTileTheme == listTileTheme &&
2011 2012 2013
        other.menuBarTheme == menuBarTheme &&
        other.menuButtonTheme == menuButtonTheme &&
        other.menuTheme == menuTheme &&
2014
        other.navigationBarTheme == navigationBarTheme &&
hangyu's avatar
hangyu committed
2015
        other.navigationDrawerTheme == navigationDrawerTheme &&
2016 2017 2018 2019 2020
        other.navigationRailTheme == navigationRailTheme &&
        other.outlinedButtonTheme == outlinedButtonTheme &&
        other.popupMenuTheme == popupMenuTheme &&
        other.progressIndicatorTheme == progressIndicatorTheme &&
        other.radioTheme == radioTheme &&
2021
        other.searchBarTheme == searchBarTheme &&
2022
        other.searchViewTheme == searchViewTheme &&
2023
        other.segmentedButtonTheme == segmentedButtonTheme &&
2024 2025 2026 2027 2028 2029 2030 2031 2032 2033
        other.sliderTheme == sliderTheme &&
        other.snackBarTheme == snackBarTheme &&
        other.switchTheme == switchTheme &&
        other.tabBarTheme == tabBarTheme &&
        other.textButtonTheme == textButtonTheme &&
        other.textSelectionTheme == textSelectionTheme &&
        other.timePickerTheme == timePickerTheme &&
        other.toggleButtonsTheme == toggleButtonsTheme &&
        other.tooltipTheme == tooltipTheme &&
        // DEPRECATED (newest deprecations at the bottom)
2034
        other.androidOverscrollIndicator == androidOverscrollIndicator &&
2035
        other.toggleableActiveColor == toggleableActiveColor &&
2036 2037
        other.selectedRowColor == selectedRowColor &&
        other.errorColor == errorColor &&
2038 2039
        other.backgroundColor == backgroundColor &&
        other.bottomAppBarColor == bottomAppBarColor;
2040
  }
2041 2042

  @override
2043
  int get hashCode {
2044
    final List<Object?> values = <Object?>[
2045 2046 2047 2048 2049
      // 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.

2050 2051 2052
      // GENERAL CONFIGURATION
      applyElevationOverlayColor,
      cupertinoOverrideTheme,
2053 2054
      ...extensions.keys,
      ...extensions.values,
2055 2056 2057 2058 2059 2060
      inputDecorationTheme,
      materialTapTargetSize,
      pageTransitionsTheme,
      platform,
      scrollbarTheme,
      splashFactory,
2061
      useMaterial3,
2062
      visualDensity,
2063
      // COLOR
2064
      canvasColor,
2065
      cardColor,
2066 2067 2068
      colorScheme,
      dialogBackgroundColor,
      disabledColor,
2069
      dividerColor,
2070
      focusColor,
2071
      highlightColor,
2072
      hintColor,
2073 2074 2075 2076 2077 2078 2079 2080 2081 2082
      hoverColor,
      indicatorColor,
      primaryColor,
      primaryColorDark,
      primaryColorLight,
      scaffoldBackgroundColor,
      secondaryHeaderColor,
      shadowColor,
      splashColor,
      unselectedWidgetColor,
2083
      // TYPOGRAPHY & ICONOGRAPHY
2084 2085
      iconTheme,
      primaryIconTheme,
2086 2087 2088
      primaryTextTheme,
      textTheme,
      typography,
2089
      // COMPONENT THEMES
2090
      actionIconTheme,
2091
      appBarTheme,
2092
      badgeTheme,
2093
      bannerTheme,
2094
      bottomAppBarTheme,
2095 2096 2097 2098 2099 2100 2101 2102
      bottomNavigationBarTheme,
      bottomSheetTheme,
      buttonBarTheme,
      buttonTheme,
      cardTheme,
      checkboxTheme,
      chipTheme,
      dataTableTheme,
2103
      datePickerTheme,
2104
      dialogTheme,
2105 2106
      dividerTheme,
      drawerTheme,
2107
      dropdownMenuTheme,
2108
      elevatedButtonTheme,
2109
      expansionTileTheme,
2110
      filledButtonTheme,
2111
      floatingActionButtonTheme,
2112
      iconButtonTheme,
2113
      listTileTheme,
2114 2115 2116
      menuBarTheme,
      menuButtonTheme,
      menuTheme,
2117
      navigationBarTheme,
hangyu's avatar
hangyu committed
2118
      navigationDrawerTheme,
2119
      navigationRailTheme,
2120
      outlinedButtonTheme,
2121 2122
      popupMenuTheme,
      progressIndicatorTheme,
2123
      radioTheme,
2124
      searchBarTheme,
2125
      searchViewTheme,
2126
      segmentedButtonTheme,
2127 2128
      sliderTheme,
      snackBarTheme,
2129
      switchTheme,
2130 2131 2132 2133 2134 2135 2136
      tabBarTheme,
      textButtonTheme,
      textSelectionTheme,
      timePickerTheme,
      toggleButtonsTheme,
      tooltipTheme,
      // DEPRECATED (newest deprecations at the bottom)
2137
      androidOverscrollIndicator,
2138
      toggleableActiveColor,
2139
      selectedRowColor,
2140 2141
      errorColor,
      backgroundColor,
2142
      bottomAppBarColor,
2143
    ];
2144
    return Object.hashAll(values);
2145
  }
Hixie's avatar
Hixie committed
2146

2147
  @override
2148 2149
  void debugFillProperties(DiagnosticPropertiesBuilder properties) {
    super.debugFillProperties(properties);
2150
    final ThemeData defaultData = ThemeData.fallback();
2151 2152 2153 2154 2155
    // 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.

2156 2157 2158
    // GENERAL CONFIGURATION
    properties.add(DiagnosticsProperty<bool>('applyElevationOverlayColor', applyElevationOverlayColor, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<NoDefaultCupertinoThemeData>('cupertinoOverrideTheme', cupertinoOverrideTheme, defaultValue: defaultData.cupertinoOverrideTheme, level: DiagnosticLevel.debug));
2159
    properties.add(IterableProperty<ThemeExtension<dynamic>>('extensions', extensions.values, defaultValue: defaultData.extensions.values, level: DiagnosticLevel.debug));
2160 2161 2162
    properties.add(DiagnosticsProperty<InputDecorationTheme>('inputDecorationTheme', inputDecorationTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<MaterialTapTargetSize>('materialTapTargetSize', materialTapTargetSize, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<PageTransitionsTheme>('pageTransitionsTheme', pageTransitionsTheme, level: DiagnosticLevel.debug));
2163
    properties.add(EnumProperty<TargetPlatform>('platform', platform, defaultValue: defaultTargetPlatform, level: DiagnosticLevel.debug));
2164 2165
    properties.add(DiagnosticsProperty<ScrollbarThemeData>('scrollbarTheme', scrollbarTheme, defaultValue: defaultData.scrollbarTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<InteractiveInkFeatureFactory>('splashFactory', splashFactory, defaultValue: defaultData.splashFactory, level: DiagnosticLevel.debug));
2166
    properties.add(DiagnosticsProperty<bool>('useMaterial3', useMaterial3, defaultValue: defaultData.useMaterial3, level: DiagnosticLevel.debug));
2167
    properties.add(DiagnosticsProperty<VisualDensity>('visualDensity', visualDensity, defaultValue: defaultData.visualDensity, level: DiagnosticLevel.debug));
2168
    // COLORS
2169
    properties.add(ColorProperty('canvasColor', canvasColor, defaultValue: defaultData.canvasColor, level: DiagnosticLevel.debug));
2170
    properties.add(ColorProperty('cardColor', cardColor, defaultValue: defaultData.cardColor, level: DiagnosticLevel.debug));
2171 2172 2173
    properties.add(DiagnosticsProperty<ColorScheme>('colorScheme', colorScheme, defaultValue: defaultData.colorScheme, level: DiagnosticLevel.debug));
    properties.add(ColorProperty('dialogBackgroundColor', dialogBackgroundColor, defaultValue: defaultData.dialogBackgroundColor, level: DiagnosticLevel.debug));
    properties.add(ColorProperty('disabledColor', disabledColor, defaultValue: defaultData.disabledColor, level: DiagnosticLevel.debug));
2174
    properties.add(ColorProperty('dividerColor', dividerColor, defaultValue: defaultData.dividerColor, level: DiagnosticLevel.debug));
2175
    properties.add(ColorProperty('focusColor', focusColor, defaultValue: defaultData.focusColor, level: DiagnosticLevel.debug));
2176 2177
    properties.add(ColorProperty('highlightColor', highlightColor, defaultValue: defaultData.highlightColor, level: DiagnosticLevel.debug));
    properties.add(ColorProperty('hintColor', hintColor, defaultValue: defaultData.hintColor, level: DiagnosticLevel.debug));
2178 2179 2180 2181 2182 2183 2184 2185 2186 2187
    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('shadowColor', shadowColor, defaultValue: defaultData.shadowColor, level: DiagnosticLevel.debug));
    properties.add(ColorProperty('splashColor', splashColor, defaultValue: defaultData.splashColor, level: DiagnosticLevel.debug));
    properties.add(ColorProperty('unselectedWidgetColor', unselectedWidgetColor, defaultValue: defaultData.unselectedWidgetColor, level: DiagnosticLevel.debug));
2188
    // TYPOGRAPHY & ICONOGRAPHY
2189 2190
    properties.add(DiagnosticsProperty<IconThemeData>('iconTheme', iconTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<IconThemeData>('primaryIconTheme', primaryIconTheme, level: DiagnosticLevel.debug));
2191 2192 2193
    properties.add(DiagnosticsProperty<TextTheme>('primaryTextTheme', primaryTextTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<TextTheme>('textTheme', textTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<Typography>('typography', typography, defaultValue: defaultData.typography, level: DiagnosticLevel.debug));
2194
    // COMPONENT THEMES
2195
    properties.add(DiagnosticsProperty<ActionIconThemeData>('actionIconTheme', actionIconTheme, level: DiagnosticLevel.debug));
2196
    properties.add(DiagnosticsProperty<AppBarTheme>('appBarTheme', appBarTheme, defaultValue: defaultData.appBarTheme, level: DiagnosticLevel.debug));
2197
    properties.add(DiagnosticsProperty<BadgeThemeData>('badgeTheme', badgeTheme, defaultValue: defaultData.badgeTheme, level: DiagnosticLevel.debug));
2198
    properties.add(DiagnosticsProperty<MaterialBannerThemeData>('bannerTheme', bannerTheme, defaultValue: defaultData.bannerTheme, level: DiagnosticLevel.debug));
2199
    properties.add(DiagnosticsProperty<BottomAppBarTheme>('bottomAppBarTheme', bottomAppBarTheme, defaultValue: defaultData.bottomAppBarTheme, level: DiagnosticLevel.debug));
2200 2201 2202 2203 2204 2205 2206 2207
    properties.add(DiagnosticsProperty<BottomNavigationBarThemeData>('bottomNavigationBarTheme', bottomNavigationBarTheme, defaultValue: defaultData.bottomNavigationBarTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<BottomSheetThemeData>('bottomSheetTheme', bottomSheetTheme, defaultValue: defaultData.bottomSheetTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<ButtonBarThemeData>('buttonBarTheme', buttonBarTheme, defaultValue: defaultData.buttonBarTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<ButtonThemeData>('buttonTheme', buttonTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<CardTheme>('cardTheme', cardTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<CheckboxThemeData>('checkboxTheme', checkboxTheme, defaultValue: defaultData.checkboxTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<ChipThemeData>('chipTheme', chipTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<DataTableThemeData>('dataTableTheme', dataTableTheme, defaultValue: defaultData.dataTableTheme, level: DiagnosticLevel.debug));
2208
    properties.add(DiagnosticsProperty<DatePickerThemeData>('datePickerTheme', datePickerTheme, defaultValue: defaultData.datePickerTheme, level: DiagnosticLevel.debug));
2209
    properties.add(DiagnosticsProperty<DialogTheme>('dialogTheme', dialogTheme, defaultValue: defaultData.dialogTheme, level: DiagnosticLevel.debug));
2210 2211
    properties.add(DiagnosticsProperty<DividerThemeData>('dividerTheme', dividerTheme, defaultValue: defaultData.dividerTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<DrawerThemeData>('drawerTheme', drawerTheme, defaultValue: defaultData.drawerTheme, level: DiagnosticLevel.debug));
2212
    properties.add(DiagnosticsProperty<DropdownMenuThemeData>('dropdownMenuTheme', dropdownMenuTheme, defaultValue: defaultData.dropdownMenuTheme, level: DiagnosticLevel.debug));
2213
    properties.add(DiagnosticsProperty<ElevatedButtonThemeData>('elevatedButtonTheme', elevatedButtonTheme, defaultValue: defaultData.elevatedButtonTheme, level: DiagnosticLevel.debug));
2214
    properties.add(DiagnosticsProperty<ExpansionTileThemeData>('expansionTileTheme', expansionTileTheme, level: DiagnosticLevel.debug));
2215
    properties.add(DiagnosticsProperty<FilledButtonThemeData>('filledButtonTheme', filledButtonTheme, defaultValue: defaultData.filledButtonTheme, level: DiagnosticLevel.debug));
2216
    properties.add(DiagnosticsProperty<FloatingActionButtonThemeData>('floatingActionButtonTheme', floatingActionButtonTheme, defaultValue: defaultData.floatingActionButtonTheme, level: DiagnosticLevel.debug));
2217
    properties.add(DiagnosticsProperty<IconButtonThemeData>('iconButtonTheme', iconButtonTheme, defaultValue: defaultData.iconButtonTheme, level: DiagnosticLevel.debug));
2218
    properties.add(DiagnosticsProperty<ListTileThemeData>('listTileTheme', listTileTheme, defaultValue: defaultData.listTileTheme, level: DiagnosticLevel.debug));
2219 2220 2221
    properties.add(DiagnosticsProperty<MenuBarThemeData>('menuBarTheme', menuBarTheme, defaultValue: defaultData.menuBarTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<MenuButtonThemeData>('menuButtonTheme', menuButtonTheme, defaultValue: defaultData.menuButtonTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<MenuThemeData>('menuTheme', menuTheme, defaultValue: defaultData.menuTheme, level: DiagnosticLevel.debug));
2222
    properties.add(DiagnosticsProperty<NavigationBarThemeData>('navigationBarTheme', navigationBarTheme, defaultValue: defaultData.navigationBarTheme, level: DiagnosticLevel.debug));
hangyu's avatar
hangyu committed
2223
    properties.add(DiagnosticsProperty<NavigationDrawerThemeData>('navigationDrawerTheme', navigationDrawerTheme, defaultValue: defaultData.navigationDrawerTheme, level: DiagnosticLevel.debug));
2224
    properties.add(DiagnosticsProperty<NavigationRailThemeData>('navigationRailTheme', navigationRailTheme, defaultValue: defaultData.navigationRailTheme, level: DiagnosticLevel.debug));
2225
    properties.add(DiagnosticsProperty<OutlinedButtonThemeData>('outlinedButtonTheme', outlinedButtonTheme, defaultValue: defaultData.outlinedButtonTheme, level: DiagnosticLevel.debug));
2226 2227
    properties.add(DiagnosticsProperty<PopupMenuThemeData>('popupMenuTheme', popupMenuTheme, defaultValue: defaultData.popupMenuTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<ProgressIndicatorThemeData>('progressIndicatorTheme', progressIndicatorTheme, defaultValue: defaultData.progressIndicatorTheme, level: DiagnosticLevel.debug));
2228
    properties.add(DiagnosticsProperty<RadioThemeData>('radioTheme', radioTheme, defaultValue: defaultData.radioTheme, level: DiagnosticLevel.debug));
2229
    properties.add(DiagnosticsProperty<SearchBarThemeData>('searchBarTheme', searchBarTheme, defaultValue: defaultData.searchBarTheme, level: DiagnosticLevel.debug));
2230
    properties.add(DiagnosticsProperty<SearchViewThemeData>('searchViewTheme', searchViewTheme, defaultValue: defaultData.searchViewTheme, level: DiagnosticLevel.debug));
2231
    properties.add(DiagnosticsProperty<SegmentedButtonThemeData>('segmentedButtonTheme', segmentedButtonTheme, defaultValue: defaultData.segmentedButtonTheme, level: DiagnosticLevel.debug));
2232 2233
    properties.add(DiagnosticsProperty<SliderThemeData>('sliderTheme', sliderTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<SnackBarThemeData>('snackBarTheme', snackBarTheme, defaultValue: defaultData.snackBarTheme, level: DiagnosticLevel.debug));
2234
    properties.add(DiagnosticsProperty<SwitchThemeData>('switchTheme', switchTheme, defaultValue: defaultData.switchTheme, level: DiagnosticLevel.debug));
2235 2236 2237 2238 2239 2240 2241
    properties.add(DiagnosticsProperty<TabBarTheme>('tabBarTheme', tabBarTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<TextButtonThemeData>('textButtonTheme', textButtonTheme, defaultValue: defaultData.textButtonTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<TextSelectionThemeData>('textSelectionTheme', textSelectionTheme, defaultValue: defaultData.textSelectionTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<TimePickerThemeData>('timePickerTheme', timePickerTheme, defaultValue: defaultData.timePickerTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<ToggleButtonsThemeData>('toggleButtonsTheme', toggleButtonsTheme, level: DiagnosticLevel.debug));
    properties.add(DiagnosticsProperty<TooltipThemeData>('tooltipTheme', tooltipTheme, level: DiagnosticLevel.debug));
    // DEPRECATED (newest deprecations at the bottom)
2242
    properties.add(EnumProperty<AndroidOverscrollIndicator>('androidOverscrollIndicator', androidOverscrollIndicator, defaultValue: null, level: DiagnosticLevel.debug));
2243
    properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor, level: DiagnosticLevel.debug));
2244
    properties.add(ColorProperty('selectedRowColor', selectedRowColor, defaultValue: defaultData.selectedRowColor, level: DiagnosticLevel.debug));
2245 2246
    properties.add(ColorProperty('errorColor', errorColor, defaultValue: defaultData.errorColor, level: DiagnosticLevel.debug));
    properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor, level: DiagnosticLevel.debug));
2247
    properties.add(ColorProperty('bottomAppBarColor', bottomAppBarColor, defaultValue: defaultData.bottomAppBarColor, level: DiagnosticLevel.debug));
xster's avatar
xster committed
2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258
  }
}

/// A [CupertinoThemeData] that defers unspecified theme attributes to an
/// upstream Material [ThemeData].
///
/// This type of [CupertinoThemeData] is used by the Material [Theme] to
/// harmonize the [CupertinoTheme] with the material theme's colors and text
/// styles.
///
/// In the most basic case, [ThemeData]'s `cupertinoOverrideTheme` is null and
2259
/// descendant Cupertino widgets' styling is derived from the Material theme.
xster's avatar
xster committed
2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285
///
/// To override individual parts of the Material-derived Cupertino styling,
/// `cupertinoOverrideTheme`'s construction parameters can be used.
///
/// To completely decouple the Cupertino styling from Material theme derivation,
/// another [CupertinoTheme] widget can be inserted as a descendant of the
/// Material [Theme]. On a [MaterialApp], this can be done using the `builder`
/// parameter on the constructor.
///
/// See also:
///
///  * [CupertinoThemeData], whose null constructor parameters default to
///    reasonable iOS styling defaults rather than harmonizing with a Material
///    theme.
///  * [Theme], widget which inserts a [CupertinoTheme] with this
///    [MaterialBasedCupertinoThemeData].
// This class subclasses CupertinoThemeData rather than composes one because it
// _is_ a CupertinoThemeData with partially altered behavior. e.g. its textTheme
// is from the superclass and based on the primaryColor but the primaryColor
// comes from the Material theme unless overridden.
class MaterialBasedCupertinoThemeData extends CupertinoThemeData {
  /// Create a [MaterialBasedCupertinoThemeData] based on a Material [ThemeData]
  /// and its `cupertinoOverrideTheme`.
  ///
  /// The [materialTheme] parameter must not be null.
  MaterialBasedCupertinoThemeData({
2286
    required ThemeData materialTheme,
2287 2288 2289 2290 2291 2292 2293 2294
  }) : this._(
    materialTheme,
    (materialTheme.cupertinoOverrideTheme ?? const CupertinoThemeData()).noDefault(),
  );

  MaterialBasedCupertinoThemeData._(
    this._materialTheme,
    this._cupertinoOverrideTheme,
2295
  ) : // Pass all values to the superclass so Material-agnostic properties
2296 2297 2298 2299 2300 2301 2302 2303 2304
      // like barBackgroundColor can still behave like a normal
      // CupertinoThemeData.
      super.raw(
        _cupertinoOverrideTheme.brightness,
        _cupertinoOverrideTheme.primaryColor,
        _cupertinoOverrideTheme.primaryContrastingColor,
        _cupertinoOverrideTheme.textTheme,
        _cupertinoOverrideTheme.barBackgroundColor,
        _cupertinoOverrideTheme.scaffoldBackgroundColor,
2305
        _cupertinoOverrideTheme.applyThemeToAll,
2306
      );
xster's avatar
xster committed
2307 2308

  final ThemeData _materialTheme;
2309
  final NoDefaultCupertinoThemeData _cupertinoOverrideTheme;
xster's avatar
xster committed
2310 2311

  @override
2312
  Brightness get brightness => _cupertinoOverrideTheme.brightness ?? _materialTheme.brightness;
xster's avatar
xster committed
2313 2314

  @override
2315
  Color get primaryColor => _cupertinoOverrideTheme.primaryColor ?? _materialTheme.colorScheme.primary;
xster's avatar
xster committed
2316 2317

  @override
2318
  Color get primaryContrastingColor => _cupertinoOverrideTheme.primaryContrastingColor ?? _materialTheme.colorScheme.onPrimary;
xster's avatar
xster committed
2319 2320

  @override
2321
  Color get scaffoldBackgroundColor => _cupertinoOverrideTheme.scaffoldBackgroundColor ?? _materialTheme.scaffoldBackgroundColor;
xster's avatar
xster committed
2322 2323 2324 2325 2326 2327 2328 2329

  /// Copies the [ThemeData]'s `cupertinoOverrideTheme`.
  ///
  /// Only the specified override attributes of the [ThemeData]'s
  /// `cupertinoOverrideTheme` and the newly specified parameters are in the
  /// returned [CupertinoThemeData]. No derived attributes from iOS defaults or
  /// from cascaded Material theme attributes are copied.
  ///
2330 2331 2332
  /// This [copyWith] cannot change the base Material [ThemeData]. To change the
  /// base Material [ThemeData], create a new Material [Theme] and use
  /// [ThemeData.copyWith] on the Material [ThemeData] instead.
xster's avatar
xster committed
2333
  @override
2334
  MaterialBasedCupertinoThemeData copyWith({
2335 2336 2337 2338 2339 2340
    Brightness? brightness,
    Color? primaryColor,
    Color? primaryContrastingColor,
    CupertinoTextThemeData? textTheme,
    Color? barBackgroundColor,
    Color? scaffoldBackgroundColor,
2341
    bool? applyThemeToAll,
xster's avatar
xster committed
2342
  }) {
2343 2344 2345 2346 2347 2348 2349 2350 2351
    return MaterialBasedCupertinoThemeData._(
      _materialTheme,
      _cupertinoOverrideTheme.copyWith(
        brightness: brightness,
        primaryColor: primaryColor,
        primaryContrastingColor: primaryContrastingColor,
        textTheme: textTheme,
        barBackgroundColor: barBackgroundColor,
        scaffoldBackgroundColor: scaffoldBackgroundColor,
2352
        applyThemeToAll: applyThemeToAll,
2353 2354 2355 2356 2357
      ),
    );
  }

  @override
2358
  CupertinoThemeData resolveFrom(BuildContext context) {
2359 2360 2361 2362
    // Only the cupertino override theme part will be resolved.
    // If the color comes from the material theme it's not resolved.
    return MaterialBasedCupertinoThemeData._(
      _materialTheme,
2363
      _cupertinoOverrideTheme.resolveFrom(context),
xster's avatar
xster committed
2364
    );
2365
  }
2366
}
2367

2368
@immutable
2369
class _IdentityThemeDataCacheKey {
2370
  const _IdentityThemeDataCacheKey(this.baseTheme, this.localTextGeometry);
2371

2372
  final ThemeData baseTheme;
2373 2374
  final TextTheme localTextGeometry;

2375 2376
  // Using XOR to make the hash function as fast as possible (e.g. Jenkins is
  // noticeably slower).
2377
  @override
2378
  int get hashCode => identityHashCode(baseTheme) ^ identityHashCode(localTextGeometry);
2379 2380

  @override
2381 2382 2383
  bool operator ==(Object other) {
    // We are explicitly ignoring the possibility that the types might not
    // match in the interests of speed.
2384 2385 2386
    return other is _IdentityThemeDataCacheKey
        && identical(other.baseTheme, baseTheme)
        && identical(other.localTextGeometry, localTextGeometry);
2387 2388 2389
  }
}

2390 2391 2392 2393 2394 2395
/// Cache of objects of limited size that uses the first in first out eviction
/// strategy (a.k.a least recently inserted).
///
/// The key that was inserted before all other keys is evicted first, i.e. the
/// one inserted least recently.
class _FifoCache<K, V> {
2396
  _FifoCache(this._maximumSize) : assert(_maximumSize > 0);
2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412

  /// In Dart the map literal uses a linked hash-map implementation, whose keys
  /// are stored such that [Map.keys] returns them in the order they were
  /// inserted.
  final Map<K, V> _cache = <K, V>{};

  /// Maximum number of entries to store in the cache.
  ///
  /// Once this many entries have been cached, the entry inserted least recently
  /// is evicted when adding a new entry.
  final int _maximumSize;

  /// Returns the previously cached value for the given key, if available;
  /// if not, calls the given callback to obtain it first.
  ///
  /// The arguments must not be null.
2413
  V putIfAbsent(K key, V Function() loader) {
2414
    assert(key != null);
2415
    final V? result = _cache[key];
2416
    if (result != null) {
2417
      return result;
2418 2419
    }
    if (_cache.length == _maximumSize) {
2420
      _cache.remove(_cache.keys.first);
2421
    }
2422 2423
    return _cache[key] = loader();
  }
2424
}
2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441

/// Defines the visual density of user interface components.
///
/// Density, in the context of a UI, is the vertical and horizontal
/// "compactness" of the components in the UI. It is unitless, since it means
/// different things to different UI components.
///
/// 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. It does not affect text sizes, icon
/// sizes, or padding values.
///
/// For example, for buttons, it affects the spacing around the child of the
/// button. For lists, it affects the distance between baselines of entries in
/// the list. For chips, it only affects the vertical size, not the horizontal
/// size.
///
2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455
/// Here are some examples of widgets that respond to density changes:
///
///  * [Checkbox]
///  * [Chip]
///  * [ElevatedButton]
///  * [IconButton]
///  * [InputDecorator] (which gives density support to [TextField], etc.)
///  * [ListTile]
///  * [MaterialButton]
///  * [OutlinedButton]
///  * [Radio]
///  * [RawMaterialButton]
///  * [TextButton]
///
2456 2457 2458 2459 2460
/// See also:
///
///  * [ThemeData.visualDensity], where this property is used to specify the base
///    horizontal density of Material components.
///  * [Material design guidance on density](https://material.io/design/layout/applying-density.html).
2461
@immutable
2462
class VisualDensity with Diagnosticable {
2463 2464 2465 2466 2467 2468 2469 2470
  /// A const constructor for [VisualDensity].
  ///
  /// All of the arguments must be non-null, and [horizontal] and [vertical]
  /// must be in the interval between [minimumDensity] and [maximumDensity],
  /// inclusive.
  const VisualDensity({
    this.horizontal = 0.0,
    this.vertical = 0.0,
2471
  }) : assert(vertical <= maximumDensity),
2472
       assert(vertical <= maximumDensity),
2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509
       assert(vertical >= minimumDensity),
       assert(horizontal <= maximumDensity),
       assert(horizontal >= minimumDensity);

  /// The minimum allowed density.
  static const double minimumDensity = -4.0;

  /// The maximum allowed density.
  static const double maximumDensity = 4.0;

  /// The default profile for [VisualDensity] in [ThemeData].
  ///
  /// This default value represents a visual density that is less dense than
  /// either [comfortable] or [compact], and corresponds to density values of
  /// zero in both axes.
  static const VisualDensity standard = VisualDensity();

  /// The profile for a "comfortable" interpretation of [VisualDensity].
  ///
  /// Individual components will interpret the density value independently,
  /// making themselves more visually dense than [standard] and less dense than
  /// [compact] to different degrees based on the Material Design specification
  /// of the "comfortable" setting for their particular use case.
  ///
  /// It corresponds to a density value of -1 in both axes.
  static const VisualDensity comfortable = VisualDensity(horizontal: -1.0, vertical: -1.0);

  /// The profile for a "compact" interpretation of [VisualDensity].
  ///
  /// Individual components will interpret the density value independently,
  /// making themselves more visually dense than [standard] and [comfortable] to
  /// different degrees based on the Material Design specification of the
  /// "comfortable" setting for their particular use case.
  ///
  /// It corresponds to a density value of -2 in both axes.
  static const VisualDensity compact = VisualDensity(horizontal: -2.0, vertical: -2.0);

2510 2511
  /// Returns a [VisualDensity] that is adaptive based on the current platform
  /// on which the framework is executing, from [defaultTargetPlatform].
2512
  ///
2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535
  /// When [defaultTargetPlatform] is a desktop platform, this returns
  /// [compact], and for other platforms, it returns a default-constructed
  /// [VisualDensity].
  ///
  /// See also:
  ///
  /// * [defaultDensityForPlatform] which returns a [VisualDensity] that is
  ///   adaptive based on the platform given to it.
  /// * [defaultTargetPlatform] which returns the platform on which the
  ///   framework is currently executing.
  static VisualDensity get adaptivePlatformDensity => defaultDensityForPlatform(defaultTargetPlatform);

  /// Returns a [VisualDensity] that is adaptive based on the given [platform].
  ///
  /// For desktop platforms, this returns [compact], and for other platforms, it
  /// returns a default-constructed [VisualDensity].
  ///
  /// See also:
  ///
  /// * [adaptivePlatformDensity] which returns a [VisualDensity] that is
  ///   adaptive based on [defaultTargetPlatform].
  static VisualDensity defaultDensityForPlatform(TargetPlatform platform) {
    switch (platform) {
2536 2537 2538 2539 2540 2541 2542 2543 2544
      case TargetPlatform.android:
      case TargetPlatform.iOS:
      case TargetPlatform.fuchsia:
        break;
      case TargetPlatform.linux:
      case TargetPlatform.macOS:
      case TargetPlatform.windows:
        return compact;
    }
2545
    return VisualDensity.standard;
2546 2547
  }

2548 2549 2550
  /// Copy the current [VisualDensity] with the given values replacing the
  /// current values.
  VisualDensity copyWith({
2551 2552
    double? horizontal,
    double? vertical,
2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594
  }) {
    return VisualDensity(
      horizontal: horizontal ?? this.horizontal,
      vertical: vertical ?? this.vertical,
    );
  }

  /// The horizontal visual density of UI components.
  ///
  /// This property affects only the horizontal spacing between and within
  /// components, to allow for different UI visual densities. It does not affect
  /// text sizes, icon sizes, or padding values. The default value is 0.0,
  /// corresponding to the metrics specified in the Material Design
  /// specification. The value can range from [minimumDensity] to
  /// [maximumDensity], inclusive.
  ///
  /// See also:
  ///
  ///  * [ThemeData.visualDensity], where this property is used to specify the base
  ///    horizontal density of Material components.
  ///  * [Material design guidance on density](https://material.io/design/layout/applying-density.html).
  final double horizontal;

  /// The vertical visual density of UI components.
  ///
  /// This property affects only the vertical spacing between and within
  /// components, to allow for different UI visual densities. It does not affect
  /// text sizes, icon sizes, or padding values. The default value is 0.0,
  /// corresponding to the metrics specified in the Material Design
  /// specification. The value can range from [minimumDensity] to
  /// [maximumDensity], inclusive.
  ///
  /// See also:
  ///
  ///  * [ThemeData.visualDensity], where this property is used to specify the base
  ///    vertical density of Material components.
  ///  * [Material design guidance on density](https://material.io/design/layout/applying-density.html).
  final double vertical;

  /// The base adjustment in logical pixels of the visual density of UI components.
  ///
  /// The input density values are multiplied by a constant to arrive at a base
2595
  /// size adjustment that fits Material Design guidelines.
2596 2597 2598 2599 2600 2601
  ///
  /// Individual components may adjust this value based upon their own
  /// individual interpretation of density.
  Offset get baseSizeAdjustment {
    // The number of logical pixels represented by an increase or decrease in
    // density by one. The Material Design guidelines say to increment/decrement
2602
    // sizes in terms of four pixel increments.
2603 2604 2605 2606 2607 2608 2609
    const double interval = 4.0;

    return Offset(horizontal, vertical) * interval;
  }

  /// Linearly interpolate between two densities.
  static VisualDensity lerp(VisualDensity a, VisualDensity b, double t) {
2610 2611 2612
    if (identical(a, b)) {
      return a;
    }
2613
    return VisualDensity(
2614
      horizontal: lerpDouble(a.horizontal, b.horizontal, t)!,
2615
      vertical: lerpDouble(a.vertical, b.vertical, t)!,
2616 2617 2618
    );
  }

2619 2620
  /// Return a copy of [constraints] whose minimum width and height have been
  /// updated with the [baseSizeAdjustment].
2621 2622 2623
  ///
  /// The resulting minWidth and minHeight values are clamped to not exceed the
  /// maxWidth and maxHeight values, respectively.
2624
  BoxConstraints effectiveConstraints(BoxConstraints constraints) {
2625
    assert(constraints.debugAssertIsValid());
2626
    return constraints.copyWith(
2627 2628
      minWidth: clampDouble(constraints.minWidth + baseSizeAdjustment.dx, 0.0, constraints.maxWidth),
      minHeight: clampDouble(constraints.minHeight + baseSizeAdjustment.dy, 0.0, constraints.maxHeight),
2629 2630 2631
    );
  }

2632
  @override
2633
  bool operator ==(Object other) {
2634 2635 2636
    if (other.runtimeType != runtimeType) {
      return false;
    }
2637 2638 2639
    return other is VisualDensity
        && other.horizontal == horizontal
        && other.vertical == vertical;
2640 2641 2642
  }

  @override
2643
  int get hashCode => Object.hash(horizontal, vertical);
2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656

  @override
  void debugFillProperties(DiagnosticPropertiesBuilder properties) {
    super.debugFillProperties(properties);
    properties.add(DoubleProperty('horizontal', horizontal, defaultValue: 0.0));
    properties.add(DoubleProperty('vertical', vertical, defaultValue: 0.0));
  }

  @override
  String toStringShort() {
    return '${super.toStringShort()}(h: ${debugFormatDouble(horizontal)}, v: ${debugFormatDouble(vertical)})';
  }
}
2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735

// BEGIN GENERATED TOKEN PROPERTIES - ColorScheme

// Do not edit by hand. The code between the "BEGIN GENERATED" and
// "END GENERATED" comments are generated from data in the Material
// Design token database by the script:
//   dev/tools/gen_defaults/bin/gen_defaults.dart.

const ColorScheme _colorSchemeLightM3 = ColorScheme(
  brightness: Brightness.light,
  primary: Color(0xFF6750A4),
  onPrimary: Color(0xFFFFFFFF),
  primaryContainer: Color(0xFFEADDFF),
  onPrimaryContainer: Color(0xFF21005D),
  secondary: Color(0xFF625B71),
  onSecondary: Color(0xFFFFFFFF),
  secondaryContainer: Color(0xFFE8DEF8),
  onSecondaryContainer: Color(0xFF1D192B),
  tertiary: Color(0xFF7D5260),
  onTertiary: Color(0xFFFFFFFF),
  tertiaryContainer: Color(0xFFFFD8E4),
  onTertiaryContainer: Color(0xFF31111D),
  error: Color(0xFFB3261E),
  onError: Color(0xFFFFFFFF),
  errorContainer: Color(0xFFF9DEDC),
  onErrorContainer: Color(0xFF410E0B),
  background: Color(0xFFFFFBFE),
  onBackground: Color(0xFF1C1B1F),
  surface: Color(0xFFFFFBFE),
  onSurface: Color(0xFF1C1B1F),
  surfaceVariant: Color(0xFFE7E0EC),
  onSurfaceVariant: Color(0xFF49454F),
  outline: Color(0xFF79747E),
  outlineVariant: Color(0xFFCAC4D0),
  shadow: Color(0xFF000000),
  scrim: Color(0xFF000000),
  inverseSurface: Color(0xFF313033),
  onInverseSurface: Color(0xFFF4EFF4),
  inversePrimary: Color(0xFFD0BCFF),
  // The surfaceTint color is set to the same color as the primary.
  surfaceTint: Color(0xFF6750A4),
);

const ColorScheme _colorSchemeDarkM3 = ColorScheme(
  brightness: Brightness.dark,
  primary: Color(0xFFD0BCFF),
  onPrimary: Color(0xFF381E72),
  primaryContainer: Color(0xFF4F378B),
  onPrimaryContainer: Color(0xFFEADDFF),
  secondary: Color(0xFFCCC2DC),
  onSecondary: Color(0xFF332D41),
  secondaryContainer: Color(0xFF4A4458),
  onSecondaryContainer: Color(0xFFE8DEF8),
  tertiary: Color(0xFFEFB8C8),
  onTertiary: Color(0xFF492532),
  tertiaryContainer: Color(0xFF633B48),
  onTertiaryContainer: Color(0xFFFFD8E4),
  error: Color(0xFFF2B8B5),
  onError: Color(0xFF601410),
  errorContainer: Color(0xFF8C1D18),
  onErrorContainer: Color(0xFFF9DEDC),
  background: Color(0xFF1C1B1F),
  onBackground: Color(0xFFE6E1E5),
  surface: Color(0xFF1C1B1F),
  onSurface: Color(0xFFE6E1E5),
  surfaceVariant: Color(0xFF49454F),
  onSurfaceVariant: Color(0xFFCAC4D0),
  outline: Color(0xFF938F99),
  outlineVariant: Color(0xFF49454F),
  shadow: Color(0xFF000000),
  scrim: Color(0xFF000000),
  inverseSurface: Color(0xFFE6E1E5),
  onInverseSurface: Color(0xFF313033),
  inversePrimary: Color(0xFF6750A4),
  // The surfaceTint color is set to the same color as the primary.
  surfaceTint: Color(0xFFD0BCFF),
);

// END GENERATED TOKEN PROPERTIES - ColorScheme