![]() |
VOOZH | about |
The List data type in Dart programming is similar to arrays in other programming languages. A list is used to represent a collection of objects. It is an ordered group of objects. The core libraries in Dart are responsible for the existence of the List class, its creation, and manipulation.
There are 5 ways to combine two or more lists:
We can add all the elements of the other list to the existing list by the use of addAll() method.
To learn about this method, you can follow this article.
Example:
Output:
[Welcome, to, GeeksForGeeks]We can add all the elements of the list one after another to a new list by the use of addAll() method in Dart.
Example:
Output:
[Welcome, to, GeeksForGeeks]We can add all the elements of the list one after another to a new list by the use of the expand() method in Dart. This is generally used to add more than two lists together.
Example:
Output:
[Welcome, to, GeeksForGeeks]We can also add lists together by the use of the + operator in Dart. This method was introduced in the Dart 2.0 update.
Example:
Output:
[Welcome, to, GeeksForGeeks]As of Dart 2.3 update, one can also use the spread operator to combine the list in Dart.
Example:
Output:
[Welcome, to, GeeksForGeeks]