How to change dropdown default text color, when it is disabled?

1.9k views Asked by At

When the dropdown is disabled it has this default black text color, which I want to change. There is an option to change the icon color but no option for text color.
Any help would be greatly appreciated.

DropdownButtonFormField(
        value: widget.selectedValue,
        items: widget.dropdownItems,
        dropdownColor: customTheme.colors.black30,
        iconEnabledColor: customTheme.colors.textColor,
        iconDisabledColor: Color.fromARGB(143, 144, 144, 144),
2

There are 2 answers

0
Jasmin Sojitra On

You can change using style

style: const TextStyle(
       color: Colors.pink,
       backgroundColor: Colors.grey,
),

Here you can find more: https://www.flutter-code.com/2021/06/flutter-dropdownbutton-selected-text.html

0
Rafael Stefani Baptista On

Change the property disabledColor of your app theme or use Theme widget:

Theme(
        data: Theme.of(context).copyWith(disabledColor: customTheme.colors.black30),
        child: DropdownButtonFormField(
            value: widget.selectedValue,
            items: widget.dropdownItems,
            dropdownColor: customTheme.colors.black30,
            iconEnabledColor: customTheme.colors.textColor,
            iconDisabledColor: Color.fromARGB(143, 144, 144, 144),
        ),
),