flutter_tags icon indicating copy to clipboard operation
flutter_tags copied to clipboard

Limitations while selecting tag

Open divyankvijayvergiya opened this issue 6 years ago • 6 comments

Can anyone please help me how do we limit the selection of tags like I just want to add 3 tags if user going to add more than 3 tags then it will show some error message. When I am trying this I am not able to restrict user while selecting tags more than 3.

divyankvijayvergiya avatar Sep 10 '19 13:09 divyankvijayvergiya

in order to find out how many are selected and change items based on it try this

onPressed: (item) {
  item.active ? selected++ : selected--;
  if (selected == 4 && item.active) {
    item.active = false;
    selected --;
  }
},

SamadiPour avatar Sep 12 '19 21:09 SamadiPour

when set item.active = false; say "active" can't be setter, because it is final

bingweibi avatar Sep 13 '19 06:09 bingweibi

I hope that when I choose a certain number of labels, then I can’t choose other. How can I achieve them?

bingweibi avatar Sep 13 '19 07:09 bingweibi

@bingweibi that's the same thing I want to ask and @SamadiPour as you mentioned item.active = false but it can't be possible because it is mentioned final in plugin if I changed that code in plugin and remove final from it still it is not changing the status of active item to inactive

divyankvijayvergiya avatar Sep 17 '19 16:09 divyankvijayvergiya

@divyankvijayvergiya yeah i was wrong and i don't know any other way :(

SamadiPour avatar Sep 17 '19 17:09 SamadiPour

As said Item class has this field active which is final else we can change it's value even the user press on it to limit selecting i'm having the same issue

Anoirwork avatar May 06 '21 06:05 Anoirwork