Add a hasNotch flag to BottomAppBar (#14856)
diff --git a/packages/flutter/lib/src/material/bottom_app_bar.dart b/packages/flutter/lib/src/material/bottom_app_bar.dart
index 41b7334..3c1898e 100644
--- a/packages/flutter/lib/src/material/bottom_app_bar.dart
+++ b/packages/flutter/lib/src/material/bottom_app_bar.dart
@@ -46,6 +46,7 @@
Key key,
this.color,
this.elevation: 8.0,
+ this.hasNotch: true,
this.child,
}) : assert(elevation != null),
assert(elevation >= 0.0),
@@ -68,6 +69,17 @@
/// Defaults to 8, the appropriate elevation for bottom app bars.
final double elevation;
+ /// Whether to make a notch in the bottom app bar's shape for the floating
+ /// action button.
+ ///
+ /// When true, the bottom app bar uses
+ /// [ScaffoldGeometry.floatingActionButtonNotch] to make a notch along its
+ /// top edge, where it is overlapped by the
+ /// [ScaffoldGeometry.floatingActionButtonArea].
+ ///
+ /// When false, the shape of the bottom app bar is a rectangle.
+ final bool hasNotch;
+
@override
State createState() => new _BottomAppBarState();
}
@@ -83,8 +95,11 @@
@override
Widget build(BuildContext context) {
+ final CustomClipper<Path> clipper = widget.hasNotch
+ ? new _BottomAppBarClipper(geometry: geometryListenable)
+ : const ShapeBorderClipper(shape: const RoundedRectangleBorder());
return new PhysicalShape(
- clipper: new _BottomAppBarClipper(geometry: geometryListenable),
+ clipper: clipper,
elevation: widget.elevation,
// TODO(amirh): use a default color from the theme.
color: widget.color ?? Colors.white,
diff --git a/packages/flutter/test/material/bottom_app_bar_test.dart b/packages/flutter/test/material/bottom_app_bar_test.dart
index 31cdba2..0ffa265 100644
--- a/packages/flutter/test/material/bottom_app_bar_test.dart
+++ b/packages/flutter/test/material/bottom_app_bar_test.dart
@@ -33,6 +33,12 @@
)
);
});
+
+ // TODO(amirh): test a BottomAppBar with hasNotch=false and an overlapping
+ // FAB.
+ //
+ // Cannot test this before https://github.com/flutter/flutter/pull/14368
+ // as there is no way to make the FAB and BAB overlap.
}
// The bottom app bar clip path computation is only available at paint time.