Verc
Verc

Reputation: 195

How to change the background color in DropDownButton?

I watched the official DropDownButton example and the background is always gray when pressed for a long time, how can I change it?

enter image description here

Upvotes: 0

Views: 199

Answers (1)

Md. Yeasin Sheikh
Md. Yeasin Sheikh

Reputation: 63569

When the DropdownButton is on focused, it uses focusColor. For the long press it uses the splashColor. Yo can wrap with Theme and provide splashColor.

Theme(
  data: ThemeData(
    splashColor: Colors.green,
  ),
  child: DropdownButton<String>(
    dropdownColor: Colors.pink, // main bg 
    focusColor: Colors.amber,// when focused
    value: dropdownValue,

Upvotes: 1

Related Questions