What is queue.addAll() in Dart?

queue.addAll()

The Dart method queue.addAll() adds all the elements present in the list.

Syntax


queue_name.addALl(List);

queue_name is the name of the queue.


Parameter

The Dart method queue.addAll() requires a list of elements to be added to the queue.

Return type

The return type is void.

Code

The following code shows how to use the queue.addAll() method in Dart.


To use a queue in a Dart program, you must first import the dart: collection module. Otherwise, you’ll get a compilation error.

import 'dart:collection';
void main() {
// Creating a Queue
Queue<String> basket = Queue<String>();
// Printing default value of queue
print(basket);
// Creating a List fruits
List<String> fruits = ["Pineapple", "Orange", "Apple", "Pear", "Banana", "Avocado"];
// Using addAll() to add all elements of the list
basket.addAll(fruits);
print(basket);
}

Free Resources