mergeList method

List<T> mergeList(
  1. List<T> items, {
  2. bool unique = false,
})

Merge the list with List items. Returns a new list with all elements of the list and items.

Implementation

List<T> mergeList(List<T> items, {bool unique = false}) {
  final list = <T>[];
  list.addAll(this);
  if (unique) {
    for (final item in items) {
      if (!list.contains(item)) list.add(item);
    }
  } else {
    list.addAll(items);
  }
  return list;
}