diff --git a/packages/dropdown_button2/lib/src/dropdown_route.dart b/packages/dropdown_button2/lib/src/dropdown_route.dart index 38f574c..d699aca 100644 --- a/packages/dropdown_button2/lib/src/dropdown_route.dart +++ b/packages/dropdown_button2/lib/src/dropdown_route.dart @@ -360,7 +360,6 @@ class _DropdownMenuRouteLayout extends SingleChildLayoutDelegate { @override BoxConstraints getConstraintsForChild(BoxConstraints constraints) { - final double? itemWidth = route.dropdownStyle.width; double maxHeight = route.getMenuAvailableHeight(availableHeight, mediaQueryPadding); final double? preferredMaxHeight = route.dropdownStyle.maxHeight; @@ -369,8 +368,9 @@ class _DropdownMenuRouteLayout extends SingleChildLayoutDelegate { } // The width of a menu should be at most the view width. This ensures that // the menu does not extend past the left and right edges of the screen. + final double? menuWidth = route.dropdownStyle.width; final double width = - math.min(constraints.maxWidth, itemWidth ?? buttonRect.width); + math.min(constraints.maxWidth, menuWidth ?? buttonRect.width); return BoxConstraints( minWidth: width, maxWidth: width, diff --git a/packages/dropdown_button2/lib/src/dropdown_style_data.dart b/packages/dropdown_button2/lib/src/dropdown_style_data.dart index 9702c1e..1a2e770 100644 --- a/packages/dropdown_button2/lib/src/dropdown_style_data.dart +++ b/packages/dropdown_button2/lib/src/dropdown_style_data.dart @@ -172,6 +172,8 @@ class DropdownStyleData { final double? maxHeight; /// The width of the dropdown menu + /// + /// If it is not provided, the width of the menu is the width of the dropdown button. final double? width; /// The inner padding of the dropdown menu