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_nameis 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
queuein a Dart program, you must first import thedart: collectionmodule. 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);}