I have 2 dropdowns. when selected item from first dropdown. I need add items to second dropdown but it giving error.
I checked the second dropdown's items is already empty. when first dropdown changed second's dropdown's items is not empty but doesn't work and gived error.
Any idea?
first dropdown code:
Widget getPolWidget() {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Icon(
Icons.touch_app,
size: 25.0,
color: Colors.black,
),
SizedBox(width: 50.0),
DropdownButton(
items: this.polList
.map((value) => DropdownMenuItem(
child: Text(
value.code,
style: TextStyle(color: Colors.black),
),
value: value.id,
))
.toList(),
onChanged: (selectedType) {
getPod(selectedType);
setState(() {
selectedPodId = selectedType;
});
},
value: selectedPodId,
isExpanded: false,
hint: Text(
'Choose Type',
style: TextStyle(color: Colors.black),
),
)
],
);
}
Widget getPodWidget() {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Icon(
Icons.touch_app,
size: 25.0,
color: Colors.black,
),
SizedBox(width: 50.0),
DropdownButton(
items: this.podList
.map((value) => DropdownMenuItem(
child: Text(
value.code,
style: TextStyle(color: Colors.black),
),
value: value.id,
))
.toList(),
onChanged: (selectedType) {
setState(() {
selectedPodId = selectedType;
print(selectedPodId);
});
},
value: selectedPodId,
isExpanded: false,
hint: Text(
'Choose Type',
style: TextStyle(color: Colors.black),
),
)
],
);
}
Error message:'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.