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);
}
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources