Unverified Commit 3e7f8b8b authored by Amir Hardon's avatar Amir Hardon Committed by GitHub

Add a clipBehavior parameter to BottomAppBar. (#21461)

Setting the default clip behavior made bottom app bar to no longer clip
its children.
With this parameter users could opt-in to clipping.
parent 7fc9165e
...@@ -41,16 +41,18 @@ import 'theme.dart'; ...@@ -41,16 +41,18 @@ import 'theme.dart';
class BottomAppBar extends StatefulWidget { class BottomAppBar extends StatefulWidget {
/// Creates a bottom application bar. /// Creates a bottom application bar.
/// ///
/// The [color] and [elevation] arguments must not be null. /// The [color], [elevation], and [clipBehavior] arguments must not be null.
const BottomAppBar({ const BottomAppBar({
Key key, Key key,
this.color, this.color,
this.elevation = 8.0, this.elevation = 8.0,
this.shape, this.shape,
this.clipBehavior = Clip.none,
this.notchMargin = 4.0, this.notchMargin = 4.0,
this.child, this.child,
}) : assert(elevation != null), }) : assert(elevation != null),
assert(elevation >= 0.0), assert(elevation >= 0.0),
assert(clipBehavior != null),
super(key: key); super(key: key);
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
...@@ -77,6 +79,9 @@ class BottomAppBar extends StatefulWidget { ...@@ -77,6 +79,9 @@ class BottomAppBar extends StatefulWidget {
/// If null the bottom app bar will be rectangular with no notch. /// If null the bottom app bar will be rectangular with no notch.
final NotchedShape shape; final NotchedShape shape;
/// {@macro flutter.widgets.Clip}
final Clip clipBehavior;
/// The margin between the [FloatingActionButton] and the [BottomAppBar]'s /// The margin between the [FloatingActionButton] and the [BottomAppBar]'s
/// notch. /// notch.
/// ///
...@@ -109,6 +114,7 @@ class _BottomAppBarState extends State<BottomAppBar> { ...@@ -109,6 +114,7 @@ class _BottomAppBarState extends State<BottomAppBar> {
clipper: clipper, clipper: clipper,
elevation: widget.elevation, elevation: widget.elevation,
color: widget.color ?? Theme.of(context).bottomAppBarColor, color: widget.color ?? Theme.of(context).bottomAppBarColor,
clipBehavior: widget.clipBehavior,
child: new Material( child: new Material(
type: MaterialType.transparency, type: MaterialType.transparency,
child: widget.child == null child: widget.child == null
......
...@@ -284,6 +284,41 @@ void main() { ...@@ -284,6 +284,41 @@ void main() {
const Offset(50.0, 550.0), const Offset(50.0, 550.0),
); );
}); });
testWidgets('clipBehavior is propagated', (WidgetTester tester) async {
await tester.pumpWidget(
new MaterialApp(
home: const Scaffold(
bottomNavigationBar:
BottomAppBar(
child: SizedBox(height: 100.0),
shape: RectangularNotch(),
notchMargin: 0.0,
),
),
),
);
PhysicalShape physicalShape = tester.widget(find.byType(PhysicalShape));
expect(physicalShape.clipBehavior, Clip.none);
await tester.pumpWidget(
new MaterialApp(
home: const Scaffold(
bottomNavigationBar:
BottomAppBar(
child: SizedBox(height: 100.0),
shape: RectangularNotch(),
notchMargin: 0.0,
clipBehavior: Clip.antiAliasWithSaveLayer,
),
),
),
);
physicalShape = tester.widget(find.byType(PhysicalShape));
expect(physicalShape.clipBehavior, Clip.antiAliasWithSaveLayer);
});
} }
// 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