Abbas Ali
Abbas Ali

Reputation: 151

Flutter dropdown alignment not proper

I want the dropdown like this with flutter

Expected:

dropdown

with flutter dropdownformfield I'm able to do something like

enter image description here

As you can see, When I click the dropdown button, the menu items are overlapping the button. Please find the code below

DropdownButtonFormField(
                            isExpanded: false,
                            isDense: true,
                            items:  classes.map((category) {
                                    return new DropdownMenuItem(
                                        value: category,
                                        child: Row(
                                          children: <Widget>[
                                            Text(category),
                                          ],
                                        ));
                                  }).toList()
                                ,
                            onChanged: (newValue) {
                              // do other stuff
                              
                            },
                            value: _classroom,
                            decoration: InputDecoration(
                              contentPadding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                              enabledBorder: UnderlineInputBorder(
                                  borderSide: BorderSide(color: Colors.white)),
                              hintText: "Select Class",
                              hintStyle: TextStyle(
                                color: Colors.grey[600],
                              ),
                            ),
                          )

is this achievable with dropdown widget? if not, how can i design custom dropdown widget?

Thanks

Upvotes: 10

Views: 3430

Answers (1)

krishnaacharyaa
krishnaacharyaa

Reputation: 24950

Use flutter's dropdownbutton2 ,In which you the menuitems are aligned from the bottom of the button, and you can even verywell customize the menu items

enter image description here

Package: DropDownButton2

For reference: Refer this link

Upvotes: 1

Related Questions