Dart CollectionDart doesn't support the array to store the data, unlike the other programming language. We can use the Dart collection in place of array data structure. We can enable the other classes of the collection in our Dart script by using the dart::core library. Dart collection can be classified as follows.
Iterating CollectionsThe dart::core library provides the iterator class, which enables the easy collection traversal. As we know that, every collection contains an iterator property. This property returns an iterator that point to the objects in the collection. Let's understand the following example. Example - Output 10 20 30 Explanation:In the above code, the moveNext() function returned the Boolean value that indicating whether there is a subsequent entry. The current property of the returns the object of that iterator currently points to. HashMap <K, V Class>The HashMap class is based on the implementation of the Map. As we discussed earlier, the key must be unique and must have consistent Object == (equal to operator) and Object.hashCode implementations. We can also use null as a key. The elements in the Map may in any order. The iteration order only changes if the map is modified. If we iterate the map, the value of the map is iterated in the same order as their associated key. Next TopicDart Generics |