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

onInsert and onDelete confusing and difficult to manage #9

Closed bzd2000 closed 4 years ago

bzd2000 commented 5 years ago

I find the onInsert and onDelete implementation difficult to manage because it changes the input tags field and also triggers to inform the parent component on an insert or on a delete. This means you cannot set it with a contructor field from the parent (which should be final) For me the input tags fields should be immutable and then

onInsert returns the the added onDelete returns the deleted eventually onChange return the complete changed list of tags

Dn-a commented 5 years ago

@bzd2000 I will make the two optional methods in the next version

bzd2000 commented 5 years ago

I think in the initstate should be changed to this (in order to make a copy of the tags in input).

@override void initState() { super.initState();

_tags = List<String>.from(widget.tags);

}

Dn-a commented 5 years ago

@bzd2000 but this way you would lose the reference from the outside

bzd2000 commented 5 years ago

@Dn-a , In my opinion, this is better to avoid that a widget can impact its parent(s) behavior. I never use use by reference, because its difficult to track down where it has been changed.

I use application state (via redux) to manage shared data.

Dn-a commented 5 years ago

@bzd2000 yes you are right, but in other contexts it is easier and more convenient to have a single external temporary list (eg you could add a specific function to change the title of a tag etc ...)

Dn-a commented 5 years ago

@bzd2000 new version 0.4.2. check and leave feedback