Dart: Collection List

# Lists in Dart 

  • Fixed Length List − The list’s length cannot change at run-time.
  • Growable List − The list’s length can change at run-time.

# Example

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:

WARNING 
ERROR 
INFO 
3 
size after removing. 
2

Leave a Reply

Your email address will not be published. Required fields are marked *