How to use + operator to combine a list in Dart
Overview
In Dart, we can also use the + operator to combine lists. The Dart 2.0 update introduced this method.
Assume we have two lists:
var list1 = [1,2,3,4];
var list2 = [5,6,7,8];
We can use the + operator to combine both lists together.
var newList = list1 + list2;
Working example
The following code shows how to use the + operator in dart:
Click the “Run” button to run the code below
void main(){// Creating the listsvar list1 = [1, 2, 3, 4];var list2 = [5, 6, 7, 8];// Using + operator to combine the listsvar newList = list1 + list2;print(newList);}