pickSegmentValue<T> method
Implementation
Future<Set<T>?> pickSegmentValue<T>(List<LabelValue<T>> items, {String? title, String? message, Set<T>? selected, bool multi = false, bool allowEmpty = true}) async {
if (!allowEmpty && (selected == null || selected.isEmpty)) selected = {items.first.value};
return showColumn(
title: title,
ok: true,
cancel: true,
onContent: (uc) {
if (!uc.hasResult) {
uc.setResult({...?selected});
}
return ColumnMinStretch([
if (message != null) messageWidget(message),
SegmentedButton<T>(
multiSelectionEnabled: multi,
emptySelectionAllowed: allowEmpty,
showSelectedIcon: false,
style: SegStyle,
segments: items.mapList((e) => ButtonSegment<T>(value: e.value, label: e.label.text())),
selected: uc.getResult()!,
onSelectionChanged: (newSelection) {
uc.setResult(newSelection);
uc.updateState();
},
),
], spacing: 16);
},
);
}