I want to add deleted items in Bin where I can restore or delete permanently. I used things which is listed below. However, I want to add deleted data in deletedList. So, How Can I? So, please help me.
List deletedList = [];
void delete() {
allCategory.removeWhere((element) => element.isSelected == true);
}
Thanks in advance.
CodePudding user response:
You can loop through allCategory list, check if isSelected==true, then first add to deletedList then remove from allCategory list.
for(int i=0; i<allCategory.length; i ){
if(allCategory[i].isSelected==true) {
deletedList.add(allCategory[i]);
allCategory.removeAt(i);
}
}
CodePudding user response:
this gonna work,
deletedItemList = (allCategory.where((element) => element.isSelected == true)).toList(); allCategory.removeWhere((element) => element.isSelected == true);