Skip to content

Commit

Permalink
Fix BottomAppBar dip without FAB (#104490)
Browse files Browse the repository at this point in the history
  • Loading branch information
TahaTesser authored May 24, 2022
1 parent d7a1b49 commit a12a69a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/flutter/lib/src/material/bottom_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ class _BottomAppBarState extends State<BottomAppBar> {
@override
Widget build(BuildContext context) {
final BottomAppBarTheme babTheme = BottomAppBarTheme.of(context);
final bool hasFab = Scaffold.of(context).hasFloatingActionButton;
final NotchedShape? notchedShape = widget.shape ?? babTheme.shape;
final CustomClipper<Path> clipper = notchedShape != null
final CustomClipper<Path> clipper = notchedShape != null && hasFab
? _BottomAppBarClipper(
geometry: geometryListenable,
shape: notchedShape,
Expand Down
25 changes: 25 additions & 0 deletions packages/flutter/test/material/bottom_app_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,31 @@ void main() {
),
);
});

testWidgets('BottomAppBar does not apply custom clipper without FAB', (WidgetTester tester) async {
Widget buildWidget({Widget? fab}) {
return MaterialApp(
home: Scaffold(
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: fab,
bottomNavigationBar: BottomAppBar(
color: Colors.green,
shape: const CircularNotchedRectangle(),
child: Container(height: 50),
),
),
);
}
await tester.pumpWidget(buildWidget(fab: FloatingActionButton(onPressed: () { })));

PhysicalShape physicalShape = tester.widget(find.byType(PhysicalShape).at(0));
expect(physicalShape.clipper.toString(), '_BottomAppBarClipper');

await tester.pumpWidget(buildWidget());

physicalShape = tester.widget(find.byType(PhysicalShape).at(0));
expect(physicalShape.clipper.toString(), 'ShapeBorderClipper');
});
}

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

0 comments on commit a12a69a

Please sign in to comment.