In this guide, we will discuss Collection List in Dart Programming Language. A List is simply an ordered group of objects. The dart:core library provides the List class that enables creation and manipulation of lists.
Lists in Dart can be classified as −
- Fixed Length List − The list’s length cannot change at run-time.
- Growable List − The list’s length can change at run-time.
Example
Given below is an example of Dart implementation of List.
void main() { List logTypes = new List(); logTypes.add("WARNING"); logTypes.add("ERROR"); logTypes.add("INFO"); // iterating across list for(String type in logTypes){ print(type); } // printing size of the list print(logTypes.length); logTypes.remove("WARNING"); print("size after removing."); print(logTypes.length); }
The output of the above code is as given below −
WARNING ERROR INFO 3 size after removing. 2
Next Topic : Click Here
Pingback: Dart Programming - Collection | Adglob Infosystem Pvt Ltd