To create an empty list in Dart, you can use empty square brackets []
or the List
constructor.
In this example,
[]
to create an empty list.emptyList
.void main() {
var emptyList = [];
print('Empty list: \$emptyList');
}
Empty list: []
In this example,
List
constructor to create an empty list of integers.emptyList
.void main() {
var emptyList = List<int>();
print('Empty list: \$emptyList');
}
Empty list: []
In this tutorial, we learned How to create an Empty List in Dart language with well detailed examples.