Unverified Commit 5f711794 authored by Henry Riehl's avatar Henry Riehl Committed by GitHub

Wire up MenuAnchor clipBehaviour property (#123632)

Wire up MenuAnchor clipBehaviour property
parent 8c5d223b
......@@ -127,7 +127,7 @@ class MenuAnchor extends StatefulWidget {
this.childFocusNode,
this.style,
this.alignmentOffset = Offset.zero,
this.clipBehavior = Clip.none,
this.clipBehavior = Clip.hardEdge,
this.anchorTapClosesMenu = false,
this.onOpen,
this.onClose,
......@@ -183,7 +183,7 @@ class MenuAnchor extends StatefulWidget {
/// {@macro flutter.material.Material.clipBehavior}
///
/// Defaults to [Clip.none].
/// Defaults to [Clip.hardEdge].
final Clip clipBehavior;
/// Whether the menus will be closed if the anchor area is tapped.
......@@ -1530,7 +1530,7 @@ class SubmenuButton extends StatefulWidget {
this.style,
this.menuStyle,
this.alignmentOffset,
this.clipBehavior = Clip.none,
this.clipBehavior = Clip.hardEdge,
this.focusNode,
this.statesController,
this.leadingIcon,
......@@ -1584,7 +1584,7 @@ class SubmenuButton extends StatefulWidget {
/// {@macro flutter.material.Material.clipBehavior}
///
/// Defaults to [Clip.none].
/// Defaults to [Clip.hardEdge].
final Clip clipBehavior;
/// {@macro flutter.widgets.Focus.focusNode}
......@@ -3312,7 +3312,7 @@ class _MenuPanelState extends State<_MenuPanel> {
shadowColor: shadowColor,
surfaceTintColor: surfaceTintColor,
type: backgroundColor == null ? MaterialType.transparency : MaterialType.canvas,
clipBehavior: Clip.hardEdge,
clipBehavior: widget.clipBehavior,
child: Padding(
padding: resolvedPadding,
child: SingleChildScrollView(
......
......@@ -945,6 +945,67 @@ void main() {
expect(material.color, equals(Colors.red));
});
testWidgets('MenuAnchor clip behavior', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
child: Center(
child: MenuAnchor(
menuChildren: const <Widget> [
MenuItemButton(
child: Text('Button 1'),
),
],
builder: (BuildContext context, MenuController controller, Widget? child) {
return FilledButton(
onPressed: () {
controller.open();
},
child: const Text('Tap me'),
);
},
),
)
)
)
);
await tester.tap(find.text('Tap me'));
await tester.pump();
// Test default clip behavior.
expect(getMenuBarMaterial(tester).clipBehavior, equals(Clip.hardEdge));
// Close the menu.
await tester.tapAt(const Offset(10.0, 10.0));
await tester.pumpAndSettle();
await tester.pumpWidget(
MaterialApp(
home: Material(
child: Center(
child: MenuAnchor(
clipBehavior: Clip.antiAlias,
menuChildren: const <Widget> [
MenuItemButton(
child: Text('Button 1'),
),
],
builder: (BuildContext context, MenuController controller, Widget? child) {
return FilledButton(
onPressed: () {
controller.open();
},
child: const Text('Tap me'),
);
},
),
)
)
)
);
await tester.tap(find.text('Tap me'));
await tester.pump();
// Test custom clip behavior.
expect(getMenuBarMaterial(tester).clipBehavior, equals(Clip.antiAlias));
});
testWidgets('open and close works', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
......@@ -2057,7 +2118,7 @@ void main() {
'focusNode: null',
'menuStyle: MenuStyle#00000(backgroundColor: MaterialStatePropertyAll(MaterialColor(primary value: Color(0xff4caf50))), elevation: MaterialStatePropertyAll(20.0), shape: MaterialStatePropertyAll(RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero)))',
'alignmentOffset: null',
'clipBehavior: none',
'clipBehavior: hardEdge',
],
),
);
......
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