I'm trying to make a dropdownbutton with int and string value in it, but I don't know how to call both string and int at the same time.
code
int selectedValue = 10;
List<DropdownMenuItem<int>> dropdownItems = [
DropdownMenuItem(
value: 10,
child: Text(
'Small',
style: TextStyle(
fontSize: 20,
fontFamily: 'Inconsolata',
fontWeight: FontWeight.bold,
color: Color(0xCBFDC4AB),
),
),
),
const DropdownMenuItem(
value: 20,
child: Text(
'Medium',
style: TextStyle(
fontSize: 20,
fontFamily: 'Inconsolata',
fontWeight: FontWeight.bold,
color: Color(0xCBFDC4AB),
),
),
),
const DropdownMenuItem(
value: 30,
child: Text(
'Large',
style: TextStyle(
fontSize: 20,
fontFamily: 'Inconsolata',
fontWeight: FontWeight.bold,
color: Color(0xCBFDC4AB),
),
),
),
];'
// the text with int value
Text(
"\$$selectedValue",
style: const TextStyle(
fontSize: 40,
fontFamily: 'Inconsolata',
fontWeight: FontWeight.bold,
color: Color(0xADFFF0E8),
),
),
// the text with string value
Text (value),
// dropdownbutton
DropdownButton(
value: selectedValue,
items: dropdownItems,
dropdownColor: Colors.brown,
underline: Container(
height: 3,
color: const Color(0xCBFDC4AB),
),
icon: Icon(
CupertinoIcons.arrowtriangle_down_fill,
color: const Color(0xCBFDC4AB),
size: 10,
shadows: [
Shadow(
color: Colors.yellow.withOpacity(0.9),
blurRadius: 10,
)
],
),
onChanged: (int? newValue) {
setState(() {
selectedValue = newValue!;
});
},
),
I want the child text to be the string value, and the value of the dropdownitem would be tre int value.
Thank you.