Open negulici-r-barnabas opened 7 months ago
I think you can override the constraints of the PopupProps.menu property.
constraints will work only when PositionCallback in menuProps in not null.
Future _openMenu() {
// Here we get the render object of our physical button, later to get its size & position
final popupButtonObject = context.findRenderObject() as RenderBox;
// Get the render object of the overlay used in `Navigator` / `MaterialApp`, i.e. screen size reference
var overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
return showCustomMenu<T>(
menuModeProps: widget.popupProps.menuProps,
context: context,
position: (widget.popupProps.menuProps.positionCallback ?? _position)(
popupButtonObject,
overlay,
),
child: _popupWidgetInstance(),
);
}
RelativeRect _position(RenderBox popupButtonObject, RenderBox overlay) {
// Calculate the show-up area for the dropdown using button's size & position based on the `overlay` used as the coordinate space.
return RelativeRect.fromSize(
Rect.fromPoints(
popupButtonObject.localToGlobal(popupButtonObject.size.bottomLeft(Offset.zero), ancestor: overlay),
popupButtonObject.localToGlobal(popupButtonObject.size.bottomRight(Offset.zero), ancestor: overlay),
),
Size(overlay.size.width, overlay.size.height),
);
}
Is there a way to increase the width of the dropdown? I noticed that I can set the height via the PopupProps.menu using fit.loose but I am having difficulty with the width. My main issue is that the items are being wrapped to two lines if one of them is longer, I need them to fit but I don't know how to make the width of the dropdown (only the dropdown) larger. Does someone know how can I make the dropdown width larger to fit the content within? I also tried to use FittedBox in itemBuilder which works but the issue there is makes the text font size smaller (scales down the item to fit).![image](https://github.com/salim-lachdhaf/searchable_dropdown/assets/109497789/284b2d0b-05be-4836-aa39-32045cd00e48)