Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

dart
data structures
communitycreator

What is queue.addAll() in Dart?

Maria Elijah

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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);
}

RELATED TAGS

dart
data structures
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring