diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart index 09ac978cef..12fe0c1863 100644 --- a/packages/flutter/lib/src/material/dialog.dart +++ b/packages/flutter/lib/src/material/dialog.dart @@ -86,6 +86,9 @@ class Dialog extends StatelessWidget { /// This sets the [Material.color] on this [Dialog]'s [Material]. /// /// If `null`, [ColorScheme.surfaceContainerHigh] is used in Material 3. + /// Otherwise, defaults to [ThemeData.dialogBackgroundColor]. + /// + /// If [Dialog.fullscreen] is used, defaults to [ColorScheme.surface]. /// {@endtemplate} final Color? backgroundColor; @@ -239,7 +242,7 @@ class Dialog extends StatelessWidget { child: ConstrainedBox( constraints: const BoxConstraints(minWidth: 280.0), child: Material( - color: backgroundColor ?? dialogTheme.backgroundColor ?? Theme.of(context).dialogBackgroundColor, + color: backgroundColor ?? dialogTheme.backgroundColor ?? defaults.backgroundColor, elevation: elevation ?? dialogTheme.elevation ?? defaults.elevation!, shadowColor: shadowColor ?? dialogTheme.shadowColor ?? defaults.shadowColor, surfaceTintColor: surfaceTintColor ?? dialogTheme.surfaceTintColor ?? defaults.surfaceTintColor, diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index 8d68dfdf5f..c5808e9e7c 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -111,11 +111,12 @@ void main() { expect(materialWidget.color, customColor); }); - testWidgets('Dialog background defaults to ColorScheme.surface', (WidgetTester tester) async { + testWidgets('Dialog background defaults to ColorScheme.surfaceContainerHigh', (WidgetTester tester) async { final ThemeData theme = ThemeData( colorScheme: ThemeData().colorScheme.copyWith( surface: Colors.orange, background: Colors.green, + surfaceContainerHigh: Colors.red, ) ); const Dialog dialog = Dialog( @@ -130,7 +131,7 @@ void main() { await tester.pumpAndSettle(); final Material materialWidget = _getMaterialFromDialog(tester); - expect(materialWidget.color, theme.colorScheme.surface); + expect(materialWidget.color, theme.colorScheme.surfaceContainerHigh); }); testWidgets('Material2 - Dialog Defaults', (WidgetTester tester) async { @@ -167,7 +168,7 @@ void main() { await tester.pumpAndSettle(); final Material material3Widget = _getMaterialFromDialog(tester); - expect(material3Widget.color, material3Theme.colorScheme.surface); + expect(material3Widget.color, material3Theme.colorScheme.surfaceContainerHigh); expect(material3Widget.shape, _defaultM3DialogShape); expect(material3Widget.elevation, 6.0); });