How to Combine Lists in Dart?
Last Updated :
15 Jul, 2025
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:
- Using the addAll() method, all the elements of another list are added to the existing list.
- Creating a new list by adding two or more lists using addAll() method of the list.
- Creating a new list by adding two or more lists using the expand() method of the list.
- Use the + operator to combine lists.
- Using the spread operator to combine lists.
1. Using addAll() Method (on an existing list)
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:
Dart
// Main function
main() {
// Creating lists
List gfg1 = ['Welcome', 'to'];
List gfg2 = ['GeeksForGeeks'];
// Combining lists
gfg1.addAll(gfg2);
// Printing combined list
print(gfg1);
}
Output:
[Welcome, to, GeeksForGeeks]
2. Creating a New List with addAll()
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:
Dart
// Main function
main() {
// Creating lists
List gfg1 = ['Welcome', 'to'];
List gfg2 = ['GeeksForGeeks'];
// Combining lists
var newgfgList = new List.from(gfg1)..addAll(gfg2);
// Printing combined list
print(newgfgList);
}
Output:
[Welcome, to, GeeksForGeeks]
3. Using expand() Method
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:
Dart
// Main function
main() {
// Creating lists
List gfg1 = ['Welcome'];
List gfg2 = ['to'];
List gfg3 = ['GeeksForGeeks'];
// Combining lists
var newgfgList = [gfg1, gfg2, gfg3].expand((x) => x).toList();
// Printing combined list
print(newgfgList);
}
Output:
[Welcome, to, GeeksForGeeks]
4. Using the + Operator
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:
Dart
// Main function
main() {
// Creating lists
List gfg1 = ['Welcome'];
List gfg2 = ['to'];
List gfg3 = ['GeeksForGeeks'];
// Combining lists
var newgfgList = gfg1 + gfg2 + gfg3;
// Printing combined list
print(newgfgList);
}
Output:
[Welcome, to, GeeksForGeeks]
5. Using the Spread Operator (...)
As of Dart 2.3 update, one can also use the spread operator to combine the list in Dart.
Example:
Dart
// Main function
main() {
// Creating lists
List gfg1 = ['Welcome'];
List gfg2 = ['to'];
List gfg3 = ['GeeksForGeeks'];
// Combining lists
var newgfgList = [...gfg1, ...gfg2, ...gfg3];
// Printing combined list
print(newgfgList);
}
Output:
[Welcome, to, GeeksForGeeks]
Explore
Dart Tutorial
7 min read
Basics
Data Types
Control Flow
Key Functions
Object-Oriented Programming
Dart Utilities
Dart Programs
Advance Concepts