dart list operations code example
Example 1: inserting elements to integer array dart
import 'dart:core';
void main() {
List<int> intArr = [1,2,3,4,5];
intArr.add(6);
intArr.addAll([7,8]);
intArr.insert(0,0);
intArr.insertAll(0,[-2,-1]);
}
Example 2: get single element from list in dart
var firstList = [1,2,3,4,5,6]; print(firstList.firstWhere((i) => i < 4));
Example 3: list dart
var fixedLengthList = List<int>.filled(5, 0);
fixedLengthList.length = 0;
fixedLengthList.add(499);
fixedLengthList[0] = 87;
var growableList = [1, 2];
growableList.length = 0;
growableList.add(499);
growableList[0] = 87;