choiceListBuilder property

S2ChoiceListBuilder<T> choiceListBuilder

Returns the choice item builder by it's current state

Implementation

S2ChoiceListBuilder<T> get choiceListBuilder {
  return (S2Choice<T> choice) {
    return choiceBuilder(
      choice.copyWith(
        selected: selection!.has(choice),
        select: ([selected = true]) {
          // set temporary value
          selection!.select(choice, selected: selected!);
          // call on choice select callback
          if (modalConfig.useConfirm == true) onSelect(choice);
          // only for single choice
          if (isSingleChoice) {
            // hide filter bar
            if (filter?.activated == true) filter?.hide(modalContext);
            // confirm the value and close modal
            if (!modalConfig.useConfirm) closeModal(confirmed: true);
          }
        },
        style: defaultChoiceStyle.merge(choiceStyle).merge(choice.style),
        activeStyle: defaultActiveChoiceStyle
            .merge(choiceStyle)
            .merge(choice.style)
            .merge(choiceActiveStyle)
            .merge(choice.activeStyle),
      ),
    );
  };
}