mirror of
https://github.com/flutter/flutter
synced 2024-09-19 16:21:58 +00:00
Fix BottomAppBar
dip without FAB (#104490)
This commit is contained in:
parent
d7a1b498ae
commit
a12a69a47c
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue