removeDuplicates method

List<T> removeDuplicates([
  1. bool compare(
    1. T a,
    2. T b
    )?
])

Return a new list without duplicated elements you can use .toSet().toList() but the order may not be the same

Implementation

List<T> removeDuplicates([bool Function(T a, T b)? compare]) {
  var tempList = <T>[];
  forEach((a) {
    if (!tempList.any((b) => compare == null ? a == b : compare(a, b))) {
      tempList.add(a);
    }
  });

  return tempList;
}