queue.addAll()
The Dart method queue.addAll()
adds all the elements present in the list.
queue_name.addALl(List);
queue_name
is the name of the queue.
The Dart method queue.addAll()
requires a list of elements to be added to the queue
.
The return type is void
.
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 thedart: collection
module. Otherwise, you’ll get a compilation error.
import 'dart:collection';void main() {// Creating a QueueQueue<String> basket = Queue<String>();// Printing default value of queueprint(basket);// Creating a List fruitsList<String> fruits = ["Pineapple", "Orange", "Apple", "Pear", "Banana", "Avocado"];// Using addAll() to add all elements of the listbasket.addAll(fruits);print(basket);}