Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/dropdown_button2/lib/src/dropdown_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ class _DropdownMenuRouteLayout<T> 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;
Expand All @@ -369,8 +368,9 @@ class _DropdownMenuRouteLayout<T> 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,
Expand Down
2 changes: 2 additions & 0 deletions packages/dropdown_button2/lib/src/dropdown_style_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down