Unverified Commit a12a69a4 authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

Fix `BottomAppBar` dip without FAB (#104490)

parent d7a1b498
...@@ -128,8 +128,9 @@ class _BottomAppBarState extends State<BottomAppBar> { ...@@ -128,8 +128,9 @@ class _BottomAppBarState extends State<BottomAppBar> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final BottomAppBarTheme babTheme = BottomAppBarTheme.of(context); final BottomAppBarTheme babTheme = BottomAppBarTheme.of(context);
final bool hasFab = Scaffold.of(context).hasFloatingActionButton;
final NotchedShape? notchedShape = widget.shape ?? babTheme.shape; final NotchedShape? notchedShape = widget.shape ?? babTheme.shape;
final CustomClipper<Path> clipper = notchedShape != null final CustomClipper<Path> clipper = notchedShape != null && hasFab
? _BottomAppBarClipper( ? _BottomAppBarClipper(
geometry: geometryListenable, geometry: geometryListenable,
shape: notchedShape, shape: notchedShape,
......
...@@ -474,6 +474,31 @@ void main() { ...@@ -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. // The bottom app bar clip path computation is only available at paint time.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment