Flutter DropdownButton show label when option is selected


Can a Dropdown Button:

 return DropdownButton<String>(
          items: <String>['Foo', 'Bar'].map((String value) {
            return new DropdownMenuItem<String>(
              value: value,
              child: new Text(value),
          onChanged: (_) {},

have something similar to a decoration user in a TextFormField:

        controller: _titleController,
        decoration: InputDecoration(labelText: 'Input'),
        validator: (String value) {
          if (value != null && value.isEmpty) {
            return 'Please enter some text';
        style: Theme.of(context).textTheme.title,

When something is written in the above TextFormField the word Input shows. Like this:

enter image description here


Replace DropdownButton with DropdownButtonFormField:


Answered By – dfmiller

Answer Checked By – Marilyn (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *