listFrom<R, E> method

List<ChipsChoiceOption<R>> listFrom <R, E>(
  1. {@required List<E> source,
  2. @required _ChipsChoiceOptionProp<E, R> value,
  3. @required _ChipsChoiceOptionProp<E, String> label,
  4. _ChipsChoiceOptionProp<E, Widget> avatar,
  5. _ChipsChoiceOptionProp<E, bool> disabled,
  6. _ChipsChoiceOptionProp<E, bool> hidden,
  7. _ChipsChoiceOptionProp<E, dynamic> meta}
)

Helper to create option list from any list

Implementation

static List<ChipsChoiceOption<R>> listFrom<R, E>({
  @required List<E> source,
  @required _ChipsChoiceOptionProp<E, R> value,
  @required _ChipsChoiceOptionProp<E, String> label,
  _ChipsChoiceOptionProp<E, Widget> avatar,
  _ChipsChoiceOptionProp<E, bool> disabled,
  _ChipsChoiceOptionProp<E, bool> hidden,
  _ChipsChoiceOptionProp<E, dynamic> meta,
}) => source
  .asMap()
  .map((index, item) => MapEntry(index, ChipsChoiceOption<R>(
    value: value?.call(index, item),
    label: label?.call(index, item),
    avatar: avatar?.call(index, item),
    disabled: disabled?.call(index, item) ?? false,
    hidden: hidden?.call(index, item) ?? false,
    meta: meta?.call(index, item),
  )))
  .values
  .toList()
  .cast<ChipsChoiceOption<R>>();