Dn-a / flutter_tags

With flutter tags you can create selectable or input tags that automatically adapt to the screen width
https://pub.dartlang.org/packages/flutter_tags
MIT License
507 stars 127 forks source link

Limitations while selecting tag #30

Open divyankvijayvergiya opened 5 years ago

divyankvijayvergiya commented 5 years ago

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.

SamadiPour commented 5 years ago

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 --;
  }
},
bingweibi commented 5 years ago

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

bingweibi commented 5 years ago

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

divyankvijayvergiya commented 5 years ago

@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

SamadiPour commented 5 years ago

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

Anoirwork commented 3 years ago

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