this error appear after i delete a category however it deletes from firebase:
Exception has occurred.
_AssertionError (‘package:flutter/src/material/dropdown.dart’: Failed assertion: line 948 pos 15: ‘items == null || items.isEmpty || value == null ||
items.where((DropdownMenuItem item) {
return item.value == value;
}).length == 1’: There should be exactly one item with [DropdownButton]’s value: Christmass.
Either zero or 2 or more [DropdownMenuItem]s were detected with the same value)
this all widget:
Widget allCat() {
return StreamBuilder(
stream: catStream,
builder: (context, AsyncSnapshot snapshot) {
return snapshot.hasData
? Column(
children: [
DropdownButton(
value: selectedValue,
hint: Text(“Choose Categorey”),
onChanged: (val) {
setState(() {
selectedValue = val;
});
},
items: [
for (ds in snapshot.data.docs) //2 snapshot.data.docs[0]
DropdownMenuItem(
value: ds[‘catName’].toString(),
child: Text(ds[‘catName’]),
),
],
),
SizedBox(
height: 20,
),
ElevatedButton(
onPressed: () async {
await DataBaseMethods().deleteCat(ds.id);
},
child: Text(“Delete Category”),
),
],
)
: Container();
});
}
momo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.