Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

+
combinelist
communitycreator
dart

How to use + operator to combine a list in Dart

Maria Elijah

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 lists
  var list1 = [1, 2, 3, 4];
  var list2 = [5, 6, 7, 8];

  //  Using + operator to combine the lists
  var newList  = list1 + list2;

  print(newList);
}
Combining the two lists

RELATED TAGS

+
combinelist
communitycreator
dart
RELATED COURSES

View all Courses

Keep Exploring