removeElement<T> function Null safety

List<T> removeElement<T>(
  1. Iterable<T>? elements,
  2. T toRemove
)

Implementation

List<T> removeElement<T>(Iterable<T>? elements, T toRemove) =>
    elements?.where((item) => item != toRemove).toList() ?? [];