Skip to content

Commit 0b5cd50

Browse files
authored
fix AppBar docs for backgroundColor & foregroundColor (#142430)
Before the M3 migration, the doc made sense. but after, it needed to specify which material version does this issue occur in. The _AppBarDefaultsM3 don't take the brightness in consideration anymore: <img width="517" alt="image" src="https://github.com/flutter/flutter/assets/124896814/d4dbe278-5b50-42d7-9143-c54d343efddf">
1 parent f8a7722 commit 0b5cd50

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,13 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
489489
/// The fill color to use for an app bar's [Material].
490490
///
491491
/// If null, then the [AppBarTheme.backgroundColor] is used. If that value is also
492-
/// null, then [AppBar] uses the overall theme's [ColorScheme.primary] if the
492+
/// null:
493+
/// In Material v2 (i.e., when [ThemeData.useMaterial3] is false),
494+
/// then [AppBar] uses the overall theme's [ColorScheme.primary] if the
493495
/// overall theme's brightness is [Brightness.light], and [ColorScheme.surface]
494496
/// if the overall theme's brightness is [Brightness.dark].
497+
/// In Material v3 (i.e., when [ThemeData.useMaterial3] is true),
498+
/// then [AppBar] uses the overall theme's [ColorScheme.surface]
495499
///
496500
/// If this color is a [MaterialStateColor] it will be resolved against
497501
/// [MaterialState.scrolledUnder] when the content of the app's
@@ -514,10 +518,13 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
514518
/// The default color for [Text] and [Icon]s within the app bar.
515519
///
516520
/// If null, then [AppBarTheme.foregroundColor] is used. If that
517-
/// value is also null, then [AppBar] uses the overall theme's
518-
/// [ColorScheme.onPrimary] if the overall theme's brightness is
519-
/// [Brightness.light], and [ColorScheme.onSurface] if the overall
520-
/// theme's brightness is [Brightness.dark].
521+
/// value is also null:
522+
/// In Material v2 (i.e., when [ThemeData.useMaterial3] is false),
523+
/// then [AppBar] uses the overall theme's [ColorScheme.onPrimary] if the
524+
/// overall theme's brightness is [Brightness.light], and [ColorScheme.onSurface]
525+
/// if the overall theme's brightness is [Brightness.dark].
526+
/// In Material v3 (i.e., when [ThemeData.useMaterial3] is true),
527+
/// then [AppBar] uses the overall theme's [ColorScheme.onSurface].
521528
///
522529
/// This color is used to configure [DefaultTextStyle] that contains
523530
/// the toolbar's children, and the default [IconTheme] widgets that

0 commit comments

Comments
 (0)