Repository navigation
Dropdown Menu layout respects menu items intrinsic sizes - #41120
Conversation
eb3453e to
04e4b1b
Compare
04e4b1b to
0583a87
Compare
shihaohong
left a comment
There was a problem hiding this comment.
The changes look good! We should add docs to explain how to properly use this with selectedItemBuilder to get the desired effect multi-line effect, which could be a separate PR.
There's also an issue with the dropdown button itself not sizing properly with taller items, as you can see with this gist.
There was a problem hiding this comment.
IIRC it attempts to position it as such, and if it fails, adjusts accordingly.
Also, it might be clearer to directly describe that it aligns the vertical center of the selected item with the vertical center of the dropdown button.
Maybe something like:
// This widget enables _DropdownRoute to look up the sizes of
// each menu item. These sizes are used to compute the offset of the selected
// item so that _DropdownRoutePage attempts to align the vertical center of the
// selected item lines up with the vertical center
// of the dropdown button.
There was a problem hiding this comment.
Sounds good, I updated the comment.
There was a problem hiding this comment.
It seems like we could remove the item property since it isn't used anywhere except in super.
There was a problem hiding this comment.
It's used by _DropdownMenuState to look up the menu item's value.
There was a problem hiding this comment.
Isn't the previous indentation okay? Although, I don't think there's guidance on this in the style guide.
There was a problem hiding this comment.
Good point, that wasn't indented properly. Fixed.
There was a problem hiding this comment.
these helper methods are really slick
0583a87 to
2ebfe83
Compare
| import 'dart:math' as math; | ||
|
|
||
| import 'package:flutter/widgets.dart'; | ||
| import 'package:flutter/rendering.dart'; |
There was a problem hiding this comment.
nit: "r" comes before "w", no?
There was a problem hiding this comment.
Good point; reordered.
|
@shihaohong per #41120 (review) |
)" This reverts commit e47a1dc.
…tter#41120)" (flutter#41422) This reverts commit e47a1dc.


Fixes #40773.
Previously, dropdown menu items had a fixed height of 48 (kMinInteractiveDimension). Dropdown menu items now have a minimum size of 48 and no maximum size. When the menu appears, each item's vertical height will match its intrinsic height.
This test case demos dropdown menus with variable height items. It also uses the new selectedItemBuilder feature to render compact versions of the selected items within the dropdown button.