CHB61 / multi_select_flutter

A flexible multi select package for Flutter. Make multi select widgets the way you want.
https://pub.dev/packages/multi_select_flutter
BSD 2-Clause "Simplified" License
241 stars 225 forks source link

onSelectionChanged value issue #178

Open Faamica opened 1 year ago

Faamica commented 1 year ago

Thanks a lot to your package.

I have written the code as below. It works fine to select 1 specific item, and then deselect it again.

But what I want is, When the user selects the 'cancel all' button, all selected item chips will be deselected.

However, in the code below, pressing the 'all cancel' button only causes the 'all cancel' item to be selected.

What if I want one specific button to deselect all the other buttons?

MultiSelectDialog(
                              initialValue: _eduableRegionSelectedList ?? [],
                              title: Text('eduableRegion',
                                  style: DGThemes.dgTextTheme.subtitle1),
                              confirmText: Text('ok',
                                  style: DGThemes.dgTextTheme.overline
                                      ?.copyWith(color: DGColors.primaryColor)),
                              cancelText: Text('no',
                                  style: DGThemes.dgTextTheme.overline),
                              selectedColor: DGColors.primaryColor,
                              selectedItemsTextStyle: DGThemes
                                  .dgTextTheme.bodyText2
                                  ?.copyWith(color: Colors.white),
                              itemsTextStyle: DGThemes.dgTextTheme.bodyText2,
                              items: siDoMulti
                                  .map(((region) =>
                                      MultiSelectItem(region, region))))
                                  .toList(),

                              onSelectionChanged: (v) {
                                if (v.contains('all cancel') == true) {
                                  v.clear();
                                  setState(() {});
                                } 
                              setState(() {});}
vaibhav891 commented 1 year ago

Hi @Faamica Did you find an answer to this? Even I am looking for something like this.

Faamica commented 1 year ago

Hi @Faamica Did you find an answer to this? Even I am looking for something like this.

nope. I don't know how to solve this. the creator(CHB61?) does not answer..