mapExceptLast<T> function

List<T> mapExceptLast<T>(
  1. Iterable<T>? list,
  2. T map(
    1. T t
    )
)

Implementation

List<T> mapExceptLast<T>(Iterable<T>? list, T map(T t)) {
  final items = list?.toList(growable: false) ?? [];
  for (var i = 0; i < items.length; ++i) {
    if (i < list!.length - 1) {
      items[i] = map(items[i]);
    }
  }
  return items;
}