Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the DropdownButton's icon color? Flutter

In Flutter, I am trying to change the color of the DropdownButton's icon (the down arrow icon) to white color.

I tried using the style property with no help. The text color became white but the icon is still the default grey.

DropdownButton(
         style: TextStyle(color: Colors.white, decorationColor: 
             Colors.white),
         items: this.items,
         value: null,
         hint: Text(SaveOptions[_saveOption], style: TextStyle(color: 
             Colors.white)),
         onChanged: (selectedOption) {
           setState(() {
             _saveOption = selectedOption;
           });
         })

How do I change the color of the arrow icon to white?

like image 594
Korenz Avatar asked Dec 25 '18 21:12

Korenz


People also ask

How do I change the color of my icon on Flutter?

Steps to change icon color in FlutterStep 1: Locate the file where you have placed the Icon widget. Step 2: Inside the Icon , add color parameter and set the color of your choice. Step 3: Run your app.

How do I change the icon color on my floating action button Flutter?

How do I change the icon color on my floating action button flutter? To change floating action button background color in Flutter, add a backgroundColor property to the FloatingActionButton widget. To change floating action button icon color, you can add a foregroundColor property and add the required color.

How do you add an icon to a dropdown in Flutter?

Use DropdownButtonFormField as it has decoration property. You can use prefixIcon attribute to set icon on left side. Save this answer.


1 Answers

You can use the fields iconEnabledColor and iconDisabledColor in the following manner:

final myDropDownMenu = DropdownButton<String>(
      iconEnabledColor: Colors.white,
      iconDisabledColor: Colors.white,
      value: myInitialValue,
      // The rest of your code
);
like image 69
AlvaroSantisteban Avatar answered Sep 20 '22 17:09

AlvaroSantisteban