How to create an empty list in Dart How to create an empty list in Dart dart dart

How to create an empty list in Dart


There are a few ways to create an empty list in Dart. If you want a growable list then use an empty list literal like this:

[]

Or this if you need to specify the type:

<String>[]

Or this if you want a non-growable (fixed-length) list:

List.empty()

Notes


Fixed Length List

 var fixedLengthList = List<int>.filled(5, 0); fixedLengthList[0] = 87;

Growable List

var growableList = [];growableList.add(499);

For more refer Docs