From a12a69a47c928e6017196f75fd9f691f32866e88 Mon Sep 17 00:00:00 2001 From: Taha Tesser Date: Tue, 24 May 2022 13:13:08 +0300 Subject: [PATCH] Fix `BottomAppBar` dip without FAB (#104490) --- .../lib/src/material/bottom_app_bar.dart | 3 ++- .../test/material/bottom_app_bar_test.dart | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/bottom_app_bar.dart b/packages/flutter/lib/src/material/bottom_app_bar.dart index 93a9300ae72c..f1b958bc84d4 100644 --- a/packages/flutter/lib/src/material/bottom_app_bar.dart +++ b/packages/flutter/lib/src/material/bottom_app_bar.dart @@ -128,8 +128,9 @@ class _BottomAppBarState extends State { @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 clipper = notchedShape != null + final CustomClipper clipper = notchedShape != null && hasFab ? _BottomAppBarClipper( geometry: geometryListenable, shape: notchedShape, diff --git a/packages/flutter/test/material/bottom_app_bar_test.dart b/packages/flutter/test/material/bottom_app_bar_test.dart index 494ad365740d..cb6901a2f6b9 100644 --- a/packages/flutter/test/material/bottom_app_bar_test.dart +++ b/packages/flutter/test/material/bottom_app_bar_test.dart @@ -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.