multi_select_flutter icon indicating copy to clipboard operation
multi_select_flutter copied to clipboard

Remove data from list is not working

Open abinvs-2019 opened this issue 4 years ago • 4 comments

List.remove(value) not working even if we call it in setstate.

abinvs-2019 avatar Dec 31 '21 06:12 abinvs-2019

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.

CHB61 avatar Jan 11 '22 23:01 CHB61

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

MuhammadSufyanMalik avatar Jan 18 '22 14:01 MuhammadSufyanMalik

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;

MuhammadSufyanMalik avatar Jan 18 '22 14:01 MuhammadSufyanMalik

Following having the same issue

isAlmogK avatar Jan 04 '23 15:01 isAlmogK