Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make rounded border for dropdownbutton in flutter?

How to Add Rounded Rectangle Border? Below Code didn't result in any border on screen.

Container(margin: EdgeInsets.only(top: 10.0, right: 10.0, left: 10.0),  width: double.infinity,  // decoration: ShapeDecoration(  //  shape: RoundedRectangleBorder(  //   borderRadius:BorderRadius.all(Radius.circular(5.0)),  //                             ),   child: DropdownButtonHideUnderline(   child: Container(    margin: EdgeInsets.only(     left: 10.0, right: 10.0),      child: new DropdownButton<UserTest>(...),                            ),                           ),                    ), 
like image 277
John Ravi Avatar asked Nov 05 '18 07:11

John Ravi


People also ask

How do you give a round border to a container in Flutter?

If you want border for all the corners you can use like bellow. Container( decoration: BoxDecoration( color: Colors. white, borderRadius: BorderRadius.

How do you style a DropDownButton in Flutter?

To change the dropdown Button color in Flutter, simply wrap your DropdownButton widget inside the Container and provide the styling instructions inside the decoration property using the BoxDecoration widget. Using the color property (insideBoxDecoration) you can assign the color.

How do I decorate the drop down menu in Flutter?

You can use DecoratedBox() to apply decoration on DropdownButton() widget. DecoratedBox provides all necessary parameters to customize the style of any kind of widget.


1 Answers

With the form field variant, you can use the OutlineInputBorder InputBorder, used normally for input text fields:

DropdownButtonFormField(   ...   decoration: const InputDecoration(     border: OutlineInputBorder(),   ), ), 

The way the form field does this can be replicated and used with the regular DropdownButton:

InputDecorator(   decoration: const InputDecoration(border: OutlineInputBorder()),   child: DropdownButtonHideUnderline(     child: DropdownButton(       ...     ),   ), ), 

Border preview

like image 162
hacker1024 Avatar answered Sep 22 '22 04:09

hacker1024