Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove data from list is not working #81

Open
abinvs-2019 opened this issue Dec 31, 2021 · 4 comments
Open

Remove data from list is not working #81

abinvs-2019 opened this issue Dec 31, 2021 · 4 comments

Comments

@abinvs-2019
Copy link

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

@CHB61
Copy link
Owner

CHB61 commented Jan 11, 2022

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.

@MuhammadSufyanMalik
Copy link

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
Copy link

MuhammadSufyanMalik commented Jan 18, 2022

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;

@isAlmogK
Copy link

isAlmogK commented Jan 4, 2023

Following having the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants