I have a dropDownFormField where I have a doprDownButton items. Every other items inside that drop down works except one that says "Thrice a week".
Tried putting a condition before setting the value of the dropdown didn't work
Expanded(
flex: 1,
child: Container(
width: 180.0,
child: DropdownButtonFormField(
decoration: InputDecoration(
filled: true,
labelText: "Frequency",
border: OutlineInputBorder(),
fillColor: Colors.black12),
validator: (val) {
if (val == null ) {
return "Select the units";
} else {
return null;
}
},
items: dummyData.frequency
.map((value) => DropdownMenuItem(
child: Text(
value,
),
value: value,
))
.toList(),
onChanged: (selectedFrequency) {
setState(() {
selectedFrequencyItem = selectedFrequency;
});
},
value: selectedFrequencyItem != null ? selectedFrequencyItem : null,
),
),
),
════════ (2) Exception caught by widgets library ═══════════════════════════════════════════════════ 'package:flutter/src/material/dropdown.dart': Failed assertion: line 620 pos 15: 'items == null || items.isEmpty || value == null || items.where((DropdownMenuItem item) => item.value == value).length == 1': is not true. User-created ancestor of the error-causing widget was:
dummyData.frequency
? This is what the error indicated onitems
. – Tokenyet