[FormBuilderChoiceChips] Add property isChoiceRequired
Can you please add isChoiceRequired bool (or sth like that) to FormBuilderChoiceChips widget? It is helpful if developer has to make choice chips like switcher between multiple choices. If isChoiceRequired == true, then initial value should be provided, or, if it's not, first choice should be chosen as initial.
Inside FormBuilderChoiceChips widget:
...
final bool isRequiredChoice;
...
this.isRequiredChoice = false, // set it to false as default in constructor
...
Inside build() method in ChoiceChip's onSelected handler:
final choice = selected ? option.value : widget.isRequiredChoice ? field.value : null;
P.S. I've made fork for this thing and it works fine, but I got tired updating it 😅
Why don't you just set the initialValue so that it is not null, and combine that with a Required validator?
Why don't you just set the
initialValueso that it is not null, and combine that with a Required validator?
Because it expands UI with error message and makes possible UI without any selected choice. As I said, this parameter (isRequiredChoice) would be helpful to create choice chips with one required choice (with default value) and without any error messages.