Remove data from list is not working
List.remove(value) not working even if we call it in setstate.
Hello,
Can you post example code? I'm assuming you're talking about removing an item from the list of selected items in the onTap of the chipDisplay?
Issue #5 or #11 might have the solution.
Hello,
Can you post example code? I'm assuming you're talking about removing an item from the list of selected items in the onTap of the chipDisplay?
Issue #5 or #11 might have the solution.
Hi, I checked issue 5, I am able to remove from the list onTap, but unable to receive values of selected items. Thanks
final List _selectedValues = [];
MultiSelectDialogField(
initialValue: _selectedValues,
buttonIcon: Icon(
Icons.arrow_drop_down,
color: primaryBlue,
),
selectedColor: primaryBlue,
selectedItemsTextStyle: TextStyle(color: whiteColor),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
border: Border.all(
color: primaryBlue,
width: 1,
),
color: whiteColor,
),
listType: MultiSelectListType.CHIP,
searchable: false,
confirmText: Text(
"Okay",
style: TextStyle(color: primaryBlue),
),
backgroundColor: backgroundColor2,
cancelText:
Text("Vazgeç", style: TextStyle(color: primaryBlue)),
title: Text("Durumlar"),
buttonText: Text("Select Durum"),
items: _items,
onConfirm: (values) {
_selectedValues.clear();
for (var i = 0; i < values.length; i++) {
StatusModel data = values[i] as StatusModel;
print(data.statusId);
print(data.statusName);
_selectedValues.add(data.statusId);
}
// _selectedValues.addAll(values);
print("data: $_selectedValues");
},
chipDisplay: MultiSelectChipDisplay(
textStyle: TextStyle(color: whiteColor),
chipColor: primaryBlue,
onTap: (values) {
// _selectedValues.removeWhere((values) => true);
_selectedValues.remove(values);
values = [];
return values;
},
),
),
By using above code , I am able to get list of values but, if I tab on one it removes all the selected. and also, after removing the values does not get empty , last values stays;
Following having the same issue