Lists

Create a list

var desserts = ['cookies', 'cupcakes', 'donuts', 'pie'];

List<String> snacks = []; //better

Methods

List class - dart:core library - Dart API
API docs for the List class from the dart:core library, for the Dart programming language.
https://api.dart.dev/be/180791/dart-core/List-class.html

Const

final desserts = const ['cookies', 'cupcakes', 'donuts', 'pie'];

. . .

// ... adds all the contents to the list
const list1 = [
 'donuts',
 ...list2,
 ...list3,
];

Collections

const deserts = ['gobi', 'sahara', 'arctic'];
var bigDeserts = [
 'ARABIAN',
 for (var desert in deserts) desert.toUpperCase(),
];
print(bigDeserts);

NULL

List<int>? nullableList = [2, 4, 3, 7];
nullableList = null;

List<int?> nullableElements = [2, 4, null, 3, 7];

List<int?>? nullableListAndElements = [2, 4, null, 3, 7];
nullableListAndElements = null;

NULL aware

List<String>? coffees;
final hotDrinks = ['milk tea', ...?coffees];
print(hotDrinks);

// avoids passing a null list to hotDrinks