mixItem method

List<T> mixItem(
  1. T item, {
  2. bool around = false,
})

混合插入元素 >>>

Implementation

List<T> mixItem(T item, {bool around = false}) {
  List<T> result = [];

  for (int i = 0; i < this.length; ++i) {
    if (i == 0) {
      if (around) {
        result.add(item);
      }
    } else {
      result.add(item);
    }
    result.add(this[i]);
  }

  if (around == true) {
    result.add(item);
  }

  return result;
}