popLabelValues<T> method

Widget popLabelValues<T>({
  1. List<LabelValue<T>>? items,
  2. List<LabelValue<T>> builder(
    1. BuildContext
    )?,
  3. Widget display(
    1. LabelValue<T>
    )?,
  4. required void callback(
    1. LabelValue<T>
    ),
  5. LabelValue<T>? initialValue,
  6. T? value,
})

Implementation

Widget popLabelValues<T>({
  List<LabelValue<T>>? items,
  List<LabelValue<T>> Function(BuildContext)? builder,
  Widget Function(LabelValue<T>)? display,
  required void Function(LabelValue<T>) callback,
  LabelValue<T>? initialValue,
  T? value,
}) {
  return PopupMenuButton<LabelValue<T>>(
    child: this,
    onSelected: (e) => callback(e),
    position: PopupMenuPosition.under,
    initialValue: initialValue ?? items?.firstOr((e) => e.value == value),
    itemBuilder: (BuildContext c) {
      List<LabelValue<T>> ls = builder?.call(c) ?? items ?? [];
      return ls.mapList((e) => PopupMenuItem<LabelValue<T>>(value: e, child: display?.call(e) ?? e.label.text()));
    },
  );
}