SegmentsBindSingle<T> function

SegmentedButton<T> SegmentsBindSingle<T>(
  1. Binder<T?> binder, {
  2. Key? key,
  3. required List<LabelValue<T>> items,
  4. bool allowEmpty = true,
})

Implementation

SegmentedButton<T> SegmentsBindSingle<T>(Binder<T?> binder, {Key? key, required List<LabelValue<T>> items, bool allowEmpty = true}) {
  return SegmentedButton<T>(
      key: key,
      multiSelectionEnabled: false,
      emptySelectionAllowed: allowEmpty,
      style: SegStyle,
      segments: items.mapList((e) => ButtonSegment(value: e.value, label: e.label.text())),
      selected: binder.value == null ? {} : {binder.value as T},
      showSelectedIcon: false,
      selectedIcon: null,
      onSelectionChanged: (vset) {
        binder.value = vset.firstOrNull;
        binder.fireUpdateUI();
        binder.fireChanged();
      });
}