Last active
May 17, 2022 14:36
-
-
Save luiscarch11/aacbaf944be4831bdd5af52dc9f0df12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension MoviesListExtension on List<Movie>{ | |
List<Movie> get cleanDuplicatedIds { | |
final moviesMap = <int, Movie>{}; | |
final moviesToReturn = <Movie>[]; | |
for (final movie in this) { | |
if (moviesMap[movie.id] == null) { | |
moviesMap[movie.id] = movie; | |
moviesToReturn.add(movie); | |
} | |
} | |
return moviesToReturn; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment