'Flutter DropdownButton - expand outside of parent element
I need the flutter dropdownbutton to be expanded much more out of its parent so all dropdown menu items would fit into it.
Now I'm using Row > Expanded > DropdownButton + isExpanded and here is the result
here is the scaffold structure:
Scaffold( ... body: Container(child: Column(children: [ ..,
Expanded(child: SingleChildScrollView(
child: Container(
child: Column(
children: [ ..,
IntrinsicHeight(
child: Expanded( flex: 4,
child: Row([ ..,
DropdownButton(
isExpanded: true,
elevation: 24
),..] ... ]
Solution 1:[1]
look at this : https://github.com/flutter/flutter/pull/14849
You can now wrap it in a ButtonTheme and set alignedDropdown to true.
Row(children: [ButtonTheme(alignedDropdown: true child:DropdownButton(...))])
Solution 2:[2]
For your problem, I would prefer you try with DropDownButton2,
The problem with the DropdownButton is that the menu will open randomly based on the selected index and other things. Also, You can't edit its code by just trying to pass offset as the logic code of the paint work based on that and trying to hardcode the selectedItemOffset to a value won't work perfectly fine.
So use DropDownButton2 , which is built just over this . In which you can customize according to your requirement !
- You can expand the menuItems, or shrink according to your requirement
- Follow this link and see some example code
Package: DropDownButton2
For reference: Refer this link
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | EDMGL |
Solution 2 | Krishna Acharya |