joinSeparator method

List<T> joinSeparator(
  1. T separator
)

Joins widgets with a separator between each item.

Parameters:

  • separator (T, required): Widget to insert between items.

Returns: List<T> — list with separators inserted.

Implementation

List<T> joinSeparator(T separator) {
  List<T> result = [];
  for (int i = 0; i < length; i++) {
    if (i > 0) {
      result.add(separator);
    }
    result.add(this[i]);
  }
  return result;
}