'Open DropDown below the selected value flutter
I need to to show dropdown below the selected value . How can we set Dropdown vertical offset in flutter like we do in android. is there a simple way to it without creating custom dropdown? image is attached and
Here is my drop down code:
Container(
width: percentWidth(77, context),
padding: EdgeInsets.fromLTRB(16, 0, 16, 0),
child: DropdownButton<String>(
isExpanded: true,
value: state.selectedSubject,
underline: Container(
height: 1.0,
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.transparent,
width: 0.0))),
),
icon: Icon(Icons.arrow_drop_down),
iconSize: 0,
elevation: 16,
style: TextStyle(color: Colors.black, fontSize: 15),
onChanged: (String data) {
_userFeedbackBloc
.add(UserFeedbackEvent.onDropDownChanged(data));
},
items: spinnerItems.map<DropdownMenuItem<String>>(
(String newValue) {
return DropdownMenuItem<String>(
value: newValue,
child: Text(newValue),
);
}).toList(),
),
),
Solution 1:[1]
Ah, here use offset my friend.
offset: Offset(0, 100),
put that good Offset inside PopupMenuButton
Solution 2:[2]
You can use CustomDropDown
https://github.com/DhavalRKansara/CustomDropDown/blob/main/custom_drop_down.dart
Copy code from above line and past In dart file
Then you can use it like below
CustomDropdownButton(
value: _selectedCompany,
items: _dropdownMenuItems,
onChanged: onChangeDropdownItem,
),
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 | Dwi Kurnianto M |
| Solution 2 | Aakash kondhalkar |
