Skip to content

Commit 0db47bd

Browse files
author
Casey Hillers
authored
Revert "Fix BottomAppBar & BottomSheet M3 shadow (#119819)" (#120492)
This reverts commit 0a97ef8.
1 parent 0346f4b commit 0db47bd

File tree

5 files changed

+6
-57
lines changed

5 files changed

+6
-57
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:flutter/foundation.dart';
66
import 'package:flutter/widgets.dart';
77

88
import 'bottom_app_bar_theme.dart';
9-
import 'colors.dart';
109
import 'elevation_overlay.dart';
1110
import 'material.dart';
1211
import 'scaffold.dart';
@@ -178,7 +177,6 @@ class _BottomAppBarState extends State<BottomAppBar> {
178177
final Color color = widget.color ?? babTheme.color ?? defaults.color!;
179178
final Color surfaceTintColor = widget.surfaceTintColor ?? babTheme.surfaceTintColor ?? defaults.surfaceTintColor!;
180179
final Color effectiveColor = isMaterial3 ? color : ElevationOverlay.applyOverlay(context, color, elevation);
181-
final Color? shadowColor = isMaterial3 ? Colors.transparent : null;
182180

183181
final Widget child = Padding(
184182
padding: widget.padding ?? babTheme.padding ?? (isMaterial3 ? const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0) : EdgeInsets.zero),
@@ -189,16 +187,15 @@ class _BottomAppBarState extends State<BottomAppBar> {
189187
height: height,
190188
child: PhysicalShape(
191189
clipper: clipper,
190+
elevation: elevation,
192191
color: effectiveColor,
193192
clipBehavior: widget.clipBehavior,
194-
elevation: isMaterial3 ? 0 : elevation,
195193
child: Material(
196194
key: materialKey,
197195
type: isMaterial3 ? MaterialType.canvas : MaterialType.transparency,
198196
elevation: elevation,
199197
color: isMaterial3 ? effectiveColor : null,
200198
surfaceTintColor: surfaceTintColor,
201-
shadowColor: shadowColor,
202199
child: SafeArea(child: child),
203200
),
204201
),

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,14 @@ class _BottomSheetState extends State<BottomSheet> {
270270

271271
@override
272272
Widget build(BuildContext context) {
273-
final bool useMaterial3 = Theme.of(context).useMaterial3;
274273
final BottomSheetThemeData bottomSheetTheme = Theme.of(context).bottomSheetTheme;
275-
final BottomSheetThemeData defaults = useMaterial3 ? _BottomSheetDefaultsM3(context) : const BottomSheetThemeData();
274+
final BottomSheetThemeData defaults = Theme.of(context).useMaterial3 ? _BottomSheetDefaultsM3(context) : const BottomSheetThemeData();
276275
final BoxConstraints? constraints = widget.constraints ?? bottomSheetTheme.constraints;
277276
final Color? color = widget.backgroundColor ?? bottomSheetTheme.backgroundColor ?? defaults.backgroundColor;
278277
final Color? surfaceTintColor = bottomSheetTheme.surfaceTintColor ?? defaults.surfaceTintColor;
279278
final double elevation = widget.elevation ?? bottomSheetTheme.elevation ?? defaults.elevation ?? 0;
280279
final ShapeBorder? shape = widget.shape ?? bottomSheetTheme.shape ?? defaults.shape;
281280
final Clip clipBehavior = widget.clipBehavior ?? bottomSheetTheme.clipBehavior ?? Clip.none;
282-
final Color? shadowColor = useMaterial3 ? Colors.transparent : null;
283281

284282
Widget bottomSheet = Material(
285283
key: _childKey,
@@ -288,7 +286,6 @@ class _BottomSheetState extends State<BottomSheet> {
288286
surfaceTintColor: surfaceTintColor,
289287
shape: shape,
290288
clipBehavior: clipBehavior,
291-
shadowColor: shadowColor,
292289
child: NotificationListener<DraggableScrollableNotification>(
293290
onNotification: extentChanged,
294291
child: widget.builder(context),

packages/flutter/test/material/bottom_app_bar_test.dart

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -233,27 +233,6 @@ void main() {
233233
expect(material.color, const Color(0xff0000ff));
234234
});
235235

236-
testWidgets('Shadow color is transparent in Material 3', (WidgetTester tester) async {
237-
await tester.pumpWidget(
238-
MaterialApp(
239-
theme: ThemeData(useMaterial3: true,
240-
),
241-
home: const Scaffold(
242-
floatingActionButton: FloatingActionButton(
243-
onPressed: null,
244-
),
245-
bottomNavigationBar: BottomAppBar(
246-
color: Color(0xff0000ff),
247-
),
248-
),
249-
)
250-
);
251-
252-
final Material material = tester.widget(find.byType(Material).at(1));
253-
254-
expect(material.shadowColor, Colors.transparent); /* no value in Material 2. */
255-
});
256-
257236
testWidgets('dark theme applies an elevation overlay color', (WidgetTester tester) async {
258237
await tester.pumpWidget(
259238
MaterialApp(

packages/flutter/test/material/bottom_app_bar_theme_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ void main() {
173173
home: const Scaffold(body: BottomAppBar()),
174174
));
175175

176-
final Material material = tester.widget(find.byType(Material).at(1));
176+
final PhysicalShape widget = _getBabRenderObject(tester);
177177

178-
expect(material.color, theme.colorScheme.surface);
179-
expect(material.elevation, equals(3.0));
178+
expect(widget.color, theme.colorScheme.surface);
179+
expect(widget.elevation, equals(3.0));
180180
});
181181

182182
testWidgets('BAB theme overrides surfaceTintColor - M3', (WidgetTester tester) async {

packages/flutter/test/material/bottom_sheet_test.dart

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ void main() {
841841
expect(modalBarrier.color, barrierColor);
842842
});
843843

844-
testWidgets('BottomSheet uses fallback values in material 3',
844+
testWidgets('BottomSheet uses fallback values in maretial3',
845845
(WidgetTester tester) async {
846846
const Color surfaceColor = Colors.pink;
847847
const Color surfaceTintColor = Colors.blue;
@@ -880,30 +880,6 @@ void main() {
880880
expect(material.shape, defaultShape);
881881
});
882882

883-
testWidgets('BottomSheet has transparent shadow in material3', (WidgetTester tester) async {
884-
await tester.pumpWidget(MaterialApp(
885-
theme: ThemeData(
886-
useMaterial3: true,
887-
),
888-
home: Scaffold(
889-
body: BottomSheet(
890-
onClosing: () {},
891-
builder: (BuildContext context) {
892-
return Container();
893-
},
894-
),
895-
),
896-
));
897-
898-
final Material material = tester.widget<Material>(
899-
find.descendant(
900-
of: find.byType(BottomSheet),
901-
matching: find.byType(Material),
902-
),
903-
);
904-
expect(material.shadowColor, Colors.transparent);
905-
});
906-
907883
testWidgets('modal BottomSheet with scrollController has semantics', (WidgetTester tester) async {
908884
final SemanticsTester semantics = SemanticsTester(tester);
909885
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();

0 commit comments

Comments
 (0)