0
Q:

declaring and initializing a list in dart

import 'dart:core';

void main() {

  //List of integers
  List<int> intArr = [1,2,3,4,5];
  print(intArr);
  
  //List of strings
  List<String> strArr = ['hello', 'world'];
  print(strArr);  
  
}
7
import 'dart:convert';
void main() { 
   var arr = new List(5);// creates an empty array of length 5
   // assigning values to all the indices
   arr[0] = 'a'; 
   arr[1] = 'b'; 
   arr[2] = 'c'; 
   arr[3] = 'd'; 
   arr[4] = 'e';  
   print(arr); 
}
2

New to Communities?

Join the community