Skip to content

Commit 5e8b5f4

Browse files
authored
Update ColorScheme.fromSwatch docs for Material 3 (flutter#136816)
part of [Clarify ColorScheme fromSwatch/fromSeed usage](flutter#132584)
1 parent e869144 commit 5e8b5f4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,16 @@ class ColorScheme with Diagnosticable {
455455
_inversePrimary = inversePrimary,
456456
_surfaceTint = surfaceTint;
457457

458-
/// Create a color scheme from a [MaterialColor] swatch.
458+
/// Creates a color scheme from a [MaterialColor] swatch.
459459
///
460-
/// This constructor is used by [ThemeData] to create its default
461-
/// color scheme.
460+
/// In Material 3, this constructor is ignored by [ThemeData] when creating
461+
/// its default color scheme. Instead, [ThemeData] uses [ ColorScheme.fromSeed]
462+
/// to create its default color scheme. This constructor shouldn't be used
463+
/// to update the Material 3 color scheme. It will be phased out gradually;
464+
/// see https://github.com/flutter/flutter/issues/91772 for more details.
465+
///
466+
/// If [ThemeData.useMaterial3] is false, then this constructor is used by
467+
/// [ThemeData] to create its default color scheme.
462468
factory ColorScheme.fromSwatch({
463469
MaterialColor primarySwatch = Colors.blue,
464470
Color? accentColor,
@@ -467,7 +473,6 @@ class ColorScheme with Diagnosticable {
467473
Color? errorColor,
468474
Brightness brightness = Brightness.light,
469475
}) {
470-
471476
final bool isDark = brightness == Brightness.dark;
472477
final bool primaryIsDark = _brightnessFor(primarySwatch) == Brightness.dark;
473478
final Color secondary = accentColor ?? (isDark ? Colors.tealAccent[200]! : primarySwatch);

0 commit comments

Comments
 (0)