skip to Main Content

I want to change the background color and border radius of DropDownButton,

i have tried it with theme but it changes the color of dropdown not the button

 Theme(
                          data: Theme.of(context)
                              .copyWith(canvasColor: Colors.blue),
                          child: DropdownButton(
                              items: [DropdownMenuItem(child: Text('one'))],
                              onChanged: (newvlaue) {}),
                        )

what i want:
enter image description here

what i get:
enter image description here

2

Answers


  1. You can use the properties dropdownColor and borderRadius to change the background color and border radius of dropdown button items:

    DropdownButton(
      items: const [
        DropdownMenuItem(child: Text('One')),
      ],
      onChanged: (dynamic newValue) {},
      dropdownColor: Colors.yellow,
      borderRadius: BorderRadius.circular(4),
    ),
    
    
    Login or Signup to reply.
  2. if you want to change the color of the button and add a radius you can wrap the dropdown button with a container.

    dropdown button wrapped with a container

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search