Skip to content

Commit 72cd152

Browse files
authored
[flutter roll] Revert "Reland "Add shadowColor and surfaceTintColor to Dialog and Di… (#109170)
1 parent 68164ad commit 72cd152

File tree

5 files changed

+12
-120
lines changed

5 files changed

+12
-120
lines changed

dev/tools/gen_defaults/lib/dialog_template.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ class _${blockName}DefaultsM3 extends DialogTheme {
2727
@override
2828
Color? get iconColor => _colors.secondary;
2929
30+
// TODO(darrenaustin): overlay should be handled by Material widget: https://github.com/flutter/flutter/issues/9160
3031
@override
31-
Color? get backgroundColor => ${componentColor("md.comp.dialog.container")};
32-
33-
@override
34-
Color? get surfaceTintColor => ${componentColor("md.comp.dialog.container.surface-tint-layer")};
32+
Color? get backgroundColor => ElevationOverlay.colorWithOverlay(${componentColor("md.comp.dialog.container")}, _colors.primary, ${elevation("md.comp.dialog.container")});
3533
3634
@override
3735
TextStyle? get titleTextStyle => ${textStyle("md.comp.dialog.headline")};

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

Lines changed: 9 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'color_scheme.dart';
1111
import 'colors.dart';
1212
import 'debug.dart';
1313
import 'dialog_theme.dart';
14+
import 'elevation_overlay.dart';
1415
import 'ink_well.dart';
1516
import 'material.dart';
1617
import 'material_localizations.dart';
@@ -45,17 +46,14 @@ class Dialog extends StatelessWidget {
4546
super.key,
4647
this.backgroundColor,
4748
this.elevation,
48-
this.shadowColor,
49-
this.surfaceTintColor,
5049
this.insetAnimationDuration = const Duration(milliseconds: 100),
5150
this.insetAnimationCurve = Curves.decelerate,
5251
this.insetPadding = _defaultInsetPadding,
5352
this.clipBehavior = Clip.none,
5453
this.shape,
5554
this.alignment,
5655
this.child,
57-
}) : assert(clipBehavior != null),
58-
assert(elevation == null || elevation >= 0.0);
56+
}) : assert(clipBehavior != null);
5957

6058
/// {@template flutter.material.dialog.backgroundColor}
6159
/// The background color of the surface of this [Dialog].
@@ -69,53 +67,12 @@ class Dialog extends StatelessWidget {
6967
/// {@template flutter.material.dialog.elevation}
7068
/// The z-coordinate of this [Dialog].
7169
///
72-
/// Controls how far above the parent the dialog will appear. Elevation is
73-
/// represented by a drop shadow if [shadowColor] is non null,
74-
/// and a surface tint overlay on the background color if [surfaceTintColor] is
75-
/// non null.
76-
///
77-
/// If null then [DialogTheme.elevation] is used, and if that is null then
78-
/// the elevation will match the Material Design specification for Dialogs.
79-
///
80-
/// See also:
81-
/// * [Material.elevation], which describes how [elevation] effects the
82-
/// drop shadow or surface tint overlay.
83-
/// * [shadowColor], color of the drop shadow used to indicate the elevation.
84-
/// * [surfaceTintColor], color of an overlay on top of the background
85-
/// color used to indicate the elevation.
86-
/// * <https://m3.material.io/components/dialogs/overview>, the Material
87-
/// Design specification for dialogs.
70+
/// If null then [DialogTheme.elevation] is used, and if that's null then the
71+
/// dialog's elevation is 24.0.
8872
/// {@endtemplate}
73+
/// {@macro flutter.material.material.elevation}
8974
final double? elevation;
9075

91-
/// {@template flutter.material.dialog.shadowColor}
92-
/// The color to paint the [elevation] shadow under the dialog's [Material].
93-
///
94-
/// If null then no drop shadow will be painted.
95-
///
96-
/// See also:
97-
/// * [Material.shadowColor], which describes how the drop shadow is painted.
98-
/// * [elevation], effects how the drop shadow is painted.
99-
/// * [surfaceTintColor], if non-null will also provide a surface tint
100-
/// overlay on the background color to indicate elevation.
101-
/// {@endtemplate}
102-
final Color? shadowColor;
103-
104-
/// {@template flutter.material.dialog.surfaceTintColor}
105-
/// The color used as a surface tint overlay on the dialog's background color,
106-
/// which reflects the dialog's [elevation].
107-
///
108-
/// If null then no surface tint will be applied.
109-
///
110-
/// See also:
111-
/// * [Material.surfaceTintColor], which describes how the surface tint will
112-
/// be applied to the background color of the dialog.
113-
/// * [elevation], effects the opacity of the surface tint.
114-
/// * [shadowColor], if non-null will also provide a drop shadow to
115-
/// indicate elevation.
116-
/// {@endtemplate}
117-
final Color? surfaceTintColor;
118-
11976
/// {@template flutter.material.dialog.insetAnimationDuration}
12077
/// The duration of the animation to show when the system keyboard intrudes
12178
/// into the space that the dialog is placed in.
@@ -198,8 +155,6 @@ class Dialog extends StatelessWidget {
198155
child: Material(
199156
color: backgroundColor ?? dialogTheme.backgroundColor ?? Theme.of(context).dialogBackgroundColor,
200157
elevation: elevation ?? dialogTheme.elevation ?? defaults.elevation!,
201-
shadowColor: shadowColor ?? dialogTheme.shadowColor ?? defaults.shadowColor,
202-
surfaceTintColor: surfaceTintColor ?? dialogTheme.surfaceTintColor ?? defaults.surfaceTintColor,
203158
shape: shape ?? dialogTheme.shape ?? defaults.shape!,
204159
type: MaterialType.card,
205160
clipBehavior: clipBehavior,
@@ -325,8 +280,6 @@ class AlertDialog extends StatelessWidget {
325280
this.buttonPadding,
326281
this.backgroundColor,
327282
this.elevation,
328-
this.shadowColor,
329-
this.surfaceTintColor,
330283
this.semanticLabel,
331284
this.insetPadding = _defaultInsetPadding,
332285
this.clipBehavior = Clip.none,
@@ -525,14 +478,9 @@ class AlertDialog extends StatelessWidget {
525478
final Color? backgroundColor;
526479

527480
/// {@macro flutter.material.dialog.elevation}
481+
/// {@macro flutter.material.material.elevation}
528482
final double? elevation;
529483

530-
/// {@macro flutter.material.dialog.shadowColor}
531-
final Color? shadowColor;
532-
533-
/// {@macro flutter.material.dialog.surfaceTintColor}
534-
final Color? surfaceTintColor;
535-
536484
/// The semantic label of the dialog used by accessibility frameworks to
537485
/// announce screen transitions when the dialog is opened and closed.
538486
///
@@ -747,8 +695,6 @@ class AlertDialog extends StatelessWidget {
747695
return Dialog(
748696
backgroundColor: backgroundColor,
749697
elevation: elevation,
750-
shadowColor: shadowColor,
751-
surfaceTintColor: surfaceTintColor,
752698
insetPadding: insetPadding,
753699
clipBehavior: clipBehavior,
754700
shape: shape,
@@ -914,8 +860,6 @@ class SimpleDialog extends StatelessWidget {
914860
this.contentPadding = const EdgeInsets.fromLTRB(0.0, 12.0, 0.0, 16.0),
915861
this.backgroundColor,
916862
this.elevation,
917-
this.shadowColor,
918-
this.surfaceTintColor,
919863
this.semanticLabel,
920864
this.insetPadding = _defaultInsetPadding,
921865
this.clipBehavior = Clip.none,
@@ -971,14 +915,9 @@ class SimpleDialog extends StatelessWidget {
971915
final Color? backgroundColor;
972916

973917
/// {@macro flutter.material.dialog.elevation}
918+
/// {@macro flutter.material.material.elevation}
974919
final double? elevation;
975920

976-
/// {@macro flutter.material.dialog.shadowColor}
977-
final Color? shadowColor;
978-
979-
/// {@macro flutter.material.dialog.surfaceTintColor}
980-
final Color? surfaceTintColor;
981-
982921
/// The semantic label of the dialog used by accessibility frameworks to
983922
/// announce screen transitions when the dialog is opened and closed.
984923
///
@@ -1092,8 +1031,6 @@ class SimpleDialog extends StatelessWidget {
10921031
return Dialog(
10931032
backgroundColor: backgroundColor,
10941033
elevation: elevation,
1095-
shadowColor: shadowColor,
1096-
surfaceTintColor: surfaceTintColor,
10971034
insetPadding: insetPadding,
10981035
clipBehavior: clipBehavior,
10991036
shape: shape,
@@ -1359,9 +1296,6 @@ class _DialogDefaultsM2 extends DialogTheme {
13591296
@override
13601297
Color? get backgroundColor => Theme.of(context).dialogBackgroundColor;
13611298

1362-
@override
1363-
Color? get shadowColor => Theme.of(context).shadowColor;
1364-
13651299
@override
13661300
TextStyle? get titleTextStyle => _textTheme.headline6;
13671301

@@ -1396,11 +1330,9 @@ class _DialogDefaultsM3 extends DialogTheme {
13961330
@override
13971331
Color? get iconColor => _colors.secondary;
13981332

1333+
// TODO(darrenaustin): overlay should be handled by Material widget: https://github.com/flutter/flutter/issues/9160
13991334
@override
1400-
Color? get backgroundColor => _colors.surface;
1401-
1402-
@override
1403-
Color? get surfaceTintColor => _colors.surfaceTint;
1335+
Color? get backgroundColor => ElevationOverlay.colorWithOverlay(_colors.surface, _colors.primary, 6.0);
14041336

14051337
@override
14061338
TextStyle? get titleTextStyle => _textTheme.headlineSmall;

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class DialogTheme with Diagnosticable {
3030
const DialogTheme({
3131
this.backgroundColor,
3232
this.elevation,
33-
this.shadowColor,
34-
this.surfaceTintColor,
3533
this.shape,
3634
this.alignment,
3735
this.iconColor,
@@ -46,12 +44,6 @@ class DialogTheme with Diagnosticable {
4644
/// Overrides the default value for [Dialog.elevation].
4745
final double? elevation;
4846

49-
/// Overrides the default value for [Dialog.shadowColor].
50-
final Color? shadowColor;
51-
52-
/// Overrides the default value for [Dialog.surfaceTintColor].
53-
final Color? surfaceTintColor;
54-
5547
/// Overrides the default value for [Dialog.shape].
5648
final ShapeBorder? shape;
5749

@@ -77,8 +69,6 @@ class DialogTheme with Diagnosticable {
7769
DialogTheme copyWith({
7870
Color? backgroundColor,
7971
double? elevation,
80-
Color? shadowColor,
81-
Color? surfaceTintColor,
8272
ShapeBorder? shape,
8373
AlignmentGeometry? alignment,
8474
Color? iconColor,
@@ -89,8 +79,6 @@ class DialogTheme with Diagnosticable {
8979
return DialogTheme(
9080
backgroundColor: backgroundColor ?? this.backgroundColor,
9181
elevation: elevation ?? this.elevation,
92-
shadowColor: shadowColor ?? this.shadowColor,
93-
surfaceTintColor: surfaceTintColor ?? this.surfaceTintColor,
9482
shape: shape ?? this.shape,
9583
alignment: alignment ?? this.alignment,
9684
iconColor: iconColor ?? this.iconColor,
@@ -115,8 +103,6 @@ class DialogTheme with Diagnosticable {
115103
return DialogTheme(
116104
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
117105
elevation: lerpDouble(a?.elevation, b?.elevation, t),
118-
shadowColor: Color.lerp(a?.shadowColor, b?.shadowColor, t),
119-
surfaceTintColor: Color.lerp(a?.surfaceTintColor, b?.surfaceTintColor, t),
120106
shape: ShapeBorder.lerp(a?.shape, b?.shape, t),
121107
alignment: AlignmentGeometry.lerp(a?.alignment, b?.alignment, t),
122108
iconColor: Color.lerp(a?.iconColor, b?.iconColor, t),
@@ -140,8 +126,6 @@ class DialogTheme with Diagnosticable {
140126
return other is DialogTheme
141127
&& other.backgroundColor == backgroundColor
142128
&& other.elevation == elevation
143-
&& other.shadowColor == shadowColor
144-
&& other.surfaceTintColor == surfaceTintColor
145129
&& other.shape == shape
146130
&& other.alignment == alignment
147131
&& other.iconColor == iconColor
@@ -155,8 +139,6 @@ class DialogTheme with Diagnosticable {
155139
super.debugFillProperties(properties);
156140
properties.add(ColorProperty('backgroundColor', backgroundColor));
157141
properties.add(DoubleProperty('elevation', elevation));
158-
properties.add(ColorProperty('shadowColor', shadowColor));
159-
properties.add(ColorProperty('surfaceTintColor', surfaceTintColor));
160142
properties.add(DiagnosticsProperty<ShapeBorder>('shape', shape, defaultValue: null));
161143
properties.add(DiagnosticsProperty<AlignmentGeometry>('alignment', alignment, defaultValue: null));
162144
properties.add(ColorProperty('iconColor', iconColor));

packages/flutter/test/material/dialog_test.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,9 @@ void main() {
140140

141141
testWidgets('Custom dialog elevation', (WidgetTester tester) async {
142142
const double customElevation = 12.0;
143-
const Color shadowColor = Color(0xFF000001);
144-
const Color surfaceTintColor = Color(0xFF000002);
145143
const AlertDialog dialog = AlertDialog(
146144
actions: <Widget>[ ],
147145
elevation: customElevation,
148-
shadowColor: shadowColor,
149-
surfaceTintColor: surfaceTintColor,
150146
);
151147
await tester.pumpWidget(_buildAppWithDialog(dialog));
152148

@@ -155,8 +151,6 @@ void main() {
155151

156152
final Material materialWidget = _getMaterialFromDialog(tester);
157153
expect(materialWidget.elevation, customElevation);
158-
expect(materialWidget.shadowColor, shadowColor);
159-
expect(materialWidget.surfaceTintColor, surfaceTintColor);
160154
});
161155

162156
testWidgets('Custom Title Text Style', (WidgetTester tester) async {

packages/flutter/test/material/dialog_theme_test.dart

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ void main() {
5151
const DialogTheme(
5252
backgroundColor: Color(0xff123456),
5353
elevation: 8.0,
54-
shadowColor: Color(0xff000001),
55-
surfaceTintColor: Color(0xff000002),
5654
alignment: Alignment.bottomLeft,
5755
iconColor: Color(0xff654321),
5856
titleTextStyle: TextStyle(color: Color(0xffffffff)),
@@ -65,8 +63,6 @@ void main() {
6563
expect(description, <String>[
6664
'backgroundColor: Color(0xff123456)',
6765
'elevation: 8.0',
68-
'shadowColor: Color(0xff000001)',
69-
'surfaceTintColor: Color(0xff000002)',
7066
'alignment: Alignment.bottomLeft',
7167
'iconColor: Color(0xff654321)',
7268
'titleTextStyle: TextStyle(inherit: true, color: Color(0xffffffff))',
@@ -93,19 +89,11 @@ void main() {
9389

9490
testWidgets('Custom dialog elevation', (WidgetTester tester) async {
9591
const double customElevation = 12.0;
96-
const Color shadowColor = Color(0xFF000001);
97-
const Color surfaceTintColor = Color(0xFF000002);
9892
const AlertDialog dialog = AlertDialog(
9993
title: Text('Title'),
10094
actions: <Widget>[ ],
10195
);
102-
final ThemeData theme = ThemeData(
103-
dialogTheme: const DialogTheme(
104-
elevation: customElevation,
105-
shadowColor: shadowColor,
106-
surfaceTintColor: surfaceTintColor,
107-
),
108-
);
96+
final ThemeData theme = ThemeData(dialogTheme: const DialogTheme(elevation: customElevation));
10997

11098
await tester.pumpWidget(
11199
_appWithDialog(tester, dialog, theme: theme),
@@ -115,8 +103,6 @@ void main() {
115103

116104
final Material materialWidget = _getMaterialFromDialog(tester);
117105
expect(materialWidget.elevation, customElevation);
118-
expect(materialWidget.shadowColor, shadowColor);
119-
expect(materialWidget.surfaceTintColor, surfaceTintColor);
120106
});
121107

122108
testWidgets('Custom dialog shape', (WidgetTester tester) async {

0 commit comments

Comments
 (0)