Make sure you are not declaring the selectedValue inside the Widget the below example works for me perfectly.

here is the working code on dartpad to test it out
var currentSelectedValue;
const deviceTypes = ["Mac", "Windows", "Mobile"];
Widget typeFieldWidget() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 20),
child: FormField<String>(
builder: (FormFieldState<String> state) {
return InputDecorator(
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0))),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
hint: Text("Select Device"),
value: currentSelectedValue,
isDense: true,
onChanged: (newValue) {
setState(() {
currentSelectedValue = newValue;
});
print(currentSelectedValue);
},
items: deviceTypes.map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
),
);
},
),
);
}
Alternate Solution
In case you are using DropDownButton in a stateless widget, You can rebuild dropDown Widget by wrapping it in ValueListenableBuilder.
class MyWidget extends StatelessWidget {
String? currentSelectedValue;
final ValueNotifier<List<String>> _listNotifier =
ValueNotifier<List<String>>(["Mac", "Windows", "Mobile"]);
Widget typeFieldWidget() {
return ValueListenableBuilder(
valueListenable: _listNotifier,
builder: (BuildContext context, List<String> list, Widget? child) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 20),
child: FormField<String>(
builder: (FormFieldState<String> state) {
return InputDecorator(
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0))),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
hint: Text("Select Device"),
value: currentSelectedValue,
isDense: true,
onChanged: (newValue) {
currentSelectedValue = newValue;
_listNotifier.notifyListeners();
},
items: list.map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
),
);
},
),
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: typeFieldWidget(),
));
}
}