List<DropdownMenuItem<String>> department = [];
@override
void initState() {
super.initState();
department.add(DropdownMenuItem(
value: 'DEP0000001',
child: Text('IT - SAP'),
));
department.add(DropdownMenuItem(
value: 'DEP0000002',
child: Text('HR - Admin'),
));
department.add(DropdownMenuItem(
value: 'DEP0000003',
child: Text('Engineering'),
));
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
DropdownButton(
items: department,
onChanged: (value) {
setState(() {
_deptCode = value;
});
},
hint: Text('Select Department'),
value: _deptCode,
),
],
),
);
}
In here I can get the value of the department code. However, I want also to get the department name. I was trying to get the String data Text widget but I think it's not possible. Is there any approach?
