dart list class code example
Example 1: 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);
}
Example 2: list dart
var fixedLengthList = List<int>.filled(5, 0);
fixedLengthList.length = 0; // Error
fixedLengthList.add(499); // Error
fixedLengthList[0] = 87;
var growableList = [1, 2];
growableList.length = 0;
growableList.add(499);
growableList[0] = 87;