dart array 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: dart have array
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);
}
Example 3: how to get data from an array of objects in dart
list[index] , //index=value(your choice)
list.last , //fetch the last value in list
//if the list contains another list inside it... then use
list.last.value1, //value1 is a field inside it