Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
YehudaKremer committed May 24, 2023
1 parent b7d453e commit c4f2db7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/src/controls/form/pickers/pickers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,17 @@ class _PickerState extends State<Picker> {

final theme = FluentTheme.of(context);

// If the screen is smaller than 260, we ensure the popup will fit in the
// screen. https://github.com/bdlukaa/fluent_ui/issues/544
final minWidth = min(260.0, MediaQuery.of(context).size.width);
final width = max(box.size.width, minWidth);
// ensure the popup will fit on the screen.
// https://github.com/bdlukaa/fluent_ui/issues/544
final minWidth = MediaQuery.of(context).size.width;
final width = min(box.size.width, minWidth);
final x = () {
if (box.size.width > minWidth) return childOffset.dx;
final popupOffset = width / 4;

// if the box width is less than [minWidth], center the popup
return childOffset.dx - (width / 4);
// use [popupOffset] only if the screen is wide enough
return width + popupOffset * 2 >= minWidth
? childOffset.dx
: childOffset.dx - popupOffset;
}();

final view = Stack(children: [
Expand Down

0 comments on commit c4f2db7

Please sign in to comment.