Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to change selected value text color in DropdownButtonFormField?

I am using dropdownbuttonformfield for creating dropdown. I need to change selected value text color white and dropdown items text color should be black as shown in image. I need to change color for image 1.
image 1

image 2

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

selectedItemBuilder: (context) {
    final List<DropdownMenuItem<String>> list = [];
    for (int i = 0; i < tpoicList.lenght; i++) {
      list.add(DropdownMenuItem<String>(
        value: tpoicList[i],
        child: Container(
          child: Text(
            value,
            style: i == dropdownValue? 
            [YourNewTextStyle],
            const TextStyle(color: Colors.black),
          ),
        ),
      ));
    }
    return list;
  },
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading