Introduction
Sometimes, we'll like to create a list which is a standard object that contains other items in an orderly manner. In this post, we'll describe how to create fixed-length and growable lists in Flutter/Dart.
How to create a list in Flutter
To create a fixed-length list in Flutter we use the List()
constructor and give a size of the list:
The output:
To create a growable list in Flutter we also use the List()
constructor but without specifying the length of the List:
The output:
Note that Flutter allows adding null
to Lists:
The output:
Conclusion
In this short tutorial, we presented how to create a List
in Flutter. There are two kinds of lists in Flutter/Dart: with fixed-length and growable, you can decide which is the best for your application.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}