@@ -534,11 +534,13 @@ class _PopupMenu<T> extends StatelessWidget {
534
534
required this .route,
535
535
required this .semanticLabel,
536
536
this .constraints,
537
+ required this .clipBehavior,
537
538
});
538
539
539
540
final _PopupMenuRoute <T > route;
540
541
final String ? semanticLabel;
541
542
final BoxConstraints ? constraints;
543
+ final Clip clipBehavior;
542
544
543
545
@override
544
546
Widget build (BuildContext context) {
@@ -607,6 +609,7 @@ class _PopupMenu<T> extends StatelessWidget {
607
609
child: Material (
608
610
shape: route.shape ?? popupMenuTheme.shape,
609
611
color: route.color ?? popupMenuTheme.color,
612
+ clipBehavior: clipBehavior,
610
613
type: MaterialType .card,
611
614
elevation: route.elevation ?? popupMenuTheme.elevation ?? 8.0 ,
612
615
child: Align (
@@ -769,6 +772,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
769
772
this .color,
770
773
required this .capturedThemes,
771
774
this .constraints,
775
+ required this .clipBehavior,
772
776
}) : itemSizes = List <Size ?>.filled (items.length, null );
773
777
774
778
final RelativeRect position;
@@ -781,6 +785,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
781
785
final Color ? color;
782
786
final CapturedThemes capturedThemes;
783
787
final BoxConstraints ? constraints;
788
+ final Clip clipBehavior;
784
789
785
790
@override
786
791
Animation <double > createAnimation () {
@@ -819,6 +824,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
819
824
route: this ,
820
825
semanticLabel: semanticLabel,
821
826
constraints: constraints,
827
+ clipBehavior: clipBehavior,
822
828
);
823
829
final MediaQueryData mediaQuery = MediaQuery .of (context);
824
830
return MediaQuery .removePadding (
@@ -896,6 +902,9 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
896
902
/// label is not provided, it will default to
897
903
/// [MaterialLocalizations.popupMenuLabel] .
898
904
///
905
+ /// The `clipBehavior` argument is used to clip the shape of the menu. Defaults to
906
+ /// [Clip.none] .
907
+ ///
899
908
/// See also:
900
909
///
901
910
/// * [PopupMenuItem] , a popup menu entry for a single value.
@@ -916,6 +925,7 @@ Future<T?> showMenu<T>({
916
925
Color ? color,
917
926
bool useRootNavigator = false ,
918
927
BoxConstraints ? constraints,
928
+ Clip clipBehavior = Clip .none,
919
929
}) {
920
930
assert (context != null );
921
931
assert (position != null );
@@ -946,6 +956,7 @@ Future<T?> showMenu<T>({
946
956
color: color,
947
957
capturedThemes: InheritedTheme .capture (from: context, to: navigator.context),
948
958
constraints: constraints,
959
+ clipBehavior: clipBehavior,
949
960
));
950
961
}
951
962
@@ -1015,6 +1026,7 @@ class PopupMenuButton<T> extends StatefulWidget {
1015
1026
this .enableFeedback,
1016
1027
this .constraints,
1017
1028
this .position = PopupMenuPosition .over,
1029
+ this .clipBehavior = Clip .none,
1018
1030
}) : assert (itemBuilder != null ),
1019
1031
assert (enabled != null ),
1020
1032
assert (
@@ -1146,6 +1158,13 @@ class PopupMenuButton<T> extends StatefulWidget {
1146
1158
/// popup menu appear directly over the button that was used to create it.
1147
1159
final PopupMenuPosition position;
1148
1160
1161
+ /// {@macro flutter.material.Material.clipBehavior}
1162
+ ///
1163
+ /// The [clipBehavior] argument is used the clip shape of the menu.
1164
+ ///
1165
+ /// Defaults to [Clip.none] , and must not be null.
1166
+ final Clip clipBehavior;
1167
+
1149
1168
@override
1150
1169
PopupMenuButtonState <T > createState () => PopupMenuButtonState <T >();
1151
1170
}
@@ -1195,6 +1214,7 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
1195
1214
shape: widget.shape ?? popupMenuTheme.shape,
1196
1215
color: widget.color ?? popupMenuTheme.color,
1197
1216
constraints: widget.constraints,
1217
+ clipBehavior: widget.clipBehavior,
1198
1218
)
1199
1219
.then <void >((T ? newValue) {
1200
1220
if (! mounted) {
0 commit comments