Skip to content

Commit a12a69a

Browse files
authored
Fix BottomAppBar dip without FAB (#104490)
1 parent d7a1b49 commit a12a69a

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ class _BottomAppBarState extends State<BottomAppBar> {
128128
@override
129129
Widget build(BuildContext context) {
130130
final BottomAppBarTheme babTheme = BottomAppBarTheme.of(context);
131+
final bool hasFab = Scaffold.of(context).hasFloatingActionButton;
131132
final NotchedShape? notchedShape = widget.shape ?? babTheme.shape;
132-
final CustomClipper<Path> clipper = notchedShape != null
133+
final CustomClipper<Path> clipper = notchedShape != null && hasFab
133134
? _BottomAppBarClipper(
134135
geometry: geometryListenable,
135136
shape: notchedShape,

packages/flutter/test/material/bottom_app_bar_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,31 @@ void main() {
474474
),
475475
);
476476
});
477+
478+
testWidgets('BottomAppBar does not apply custom clipper without FAB', (WidgetTester tester) async {
479+
Widget buildWidget({Widget? fab}) {
480+
return MaterialApp(
481+
home: Scaffold(
482+
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
483+
floatingActionButton: fab,
484+
bottomNavigationBar: BottomAppBar(
485+
color: Colors.green,
486+
shape: const CircularNotchedRectangle(),
487+
child: Container(height: 50),
488+
),
489+
),
490+
);
491+
}
492+
await tester.pumpWidget(buildWidget(fab: FloatingActionButton(onPressed: () { })));
493+
494+
PhysicalShape physicalShape = tester.widget(find.byType(PhysicalShape).at(0));
495+
expect(physicalShape.clipper.toString(), '_BottomAppBarClipper');
496+
497+
await tester.pumpWidget(buildWidget());
498+
499+
physicalShape = tester.widget(find.byType(PhysicalShape).at(0));
500+
expect(physicalShape.clipper.toString(), 'ShapeBorderClipper');
501+
});
477502
}
478503

479504
// The bottom app bar clip path computation is only available at paint time.

0 commit comments

Comments
 (0)