Use toSet
and then toList
var ids = [1, 4, 4, 4, 5, 6, 6];
var distinctIds = ids.toSet().toList();
Result: [1, 4, 5, 6]
Or with spread operators:
var distinctIds = [...{...ids}];
More Related Contents:
- Sort a list of objects in Flutter (Dart) by property value
- How do I split or chunk a list into equal parts, with Dart?
- In Dart, what’s the difference between List.from and .of, and between Map.from and .of?
- List.shuffle() in Dart?
- How to count items’ occurence in a List
- My async call is returning before list is populated in forEach loop
- Concatenating two lists – difference between ‘+=’ and extend()
- Test if lists share any items in python
- How to check if all of the following items are in a list?
- Convert a matrix to a list of column-vectors
- Search for an item in a Lua list
- Decrementing ranges in Haskell
- Java 8: sort list of objects by attribute without custom comparator
- How can I sort a list of strings in Dart?
- Lazy lists in Prolog?
- Zip with default value instead of dropping values?
- How to clone or copy a list in kotlin
- Replace individual list elements in Haskell?
- How to count number of element occurrences in a list in Prolog
- Intersection and union of 2 lists
- How to recursively reverse a list using only basic operations?
- Difference between a Seq and a List in Scala
- XPath 1.0 to find if an element’s value is in a list of values
- How can I read the contents of a file into a list in Lisp?
- R: Print list to a text file
- Add or remove an entry from a List type attribute in a DynamoDB table item
- Removing syntactic sugar: List comprehension in Haskell
- Counting unique elements in a list
- Unsequence Monad function within Haskell
- Prolog, find minimum in a list