separatorEvery method

List<T> separatorEvery(
  1. T separator, {
  2. bool start = false,
  3. bool end = false,
})

Implementation

List<T> separatorEvery(T separator, {bool start = false, bool end = false}) {
  List<T> list = <T>[];
  if (isNullOrEmpty) return list;

  ///First item Top separator
  if (start) {
    list.add(separator);
  }
  for (int n = 0; n < (this?.length ?? 0); n++) {
    if (end) {
      list.addAll([this![n], separator]);
      continue;
    }
    if (!end && (n == ((this?.length ?? 1) - 1))) {
      list.add(this![n]);
    }
  }
  return list;
}