Skip to content

Commit 1f3eb50

Browse files
authored
Add a hasNotch flag to BottomAppBar (flutter#14856)
1 parent c6e7ad1 commit 1f3eb50

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class BottomAppBar extends StatefulWidget {
4646
Key key,
4747
this.color,
4848
this.elevation: 8.0,
49+
this.hasNotch: true,
4950
this.child,
5051
}) : assert(elevation != null),
5152
assert(elevation >= 0.0),
@@ -68,6 +69,17 @@ class BottomAppBar extends StatefulWidget {
6869
/// Defaults to 8, the appropriate elevation for bottom app bars.
6970
final double elevation;
7071

72+
/// Whether to make a notch in the bottom app bar's shape for the floating
73+
/// action button.
74+
///
75+
/// When true, the bottom app bar uses
76+
/// [ScaffoldGeometry.floatingActionButtonNotch] to make a notch along its
77+
/// top edge, where it is overlapped by the
78+
/// [ScaffoldGeometry.floatingActionButtonArea].
79+
///
80+
/// When false, the shape of the bottom app bar is a rectangle.
81+
final bool hasNotch;
82+
7183
@override
7284
State createState() => new _BottomAppBarState();
7385
}
@@ -83,8 +95,11 @@ class _BottomAppBarState extends State<BottomAppBar> {
8395

8496
@override
8597
Widget build(BuildContext context) {
98+
final CustomClipper<Path> clipper = widget.hasNotch
99+
? new _BottomAppBarClipper(geometry: geometryListenable)
100+
: const ShapeBorderClipper(shape: const RoundedRectangleBorder());
86101
return new PhysicalShape(
87-
clipper: new _BottomAppBarClipper(geometry: geometryListenable),
102+
clipper: clipper,
88103
elevation: widget.elevation,
89104
// TODO(amirh): use a default color from the theme.
90105
color: widget.color ?? Colors.white,

packages/flutter/test/material/bottom_app_bar_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ void main() {
3333
)
3434
);
3535
});
36+
37+
// TODO(amirh): test a BottomAppBar with hasNotch=false and an overlapping
38+
// FAB.
39+
//
40+
// Cannot test this before https://github.com/flutter/flutter/pull/14368
41+
// as there is no way to make the FAB and BAB overlap.
3642
}
3743

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

0 commit comments

Comments
 (0)