The queue.length
function in Dart returns the number of elements in the queue. In short, this function is used to get the current size of the queue.
The image below shows the visual representation of the queue.length
function.
int queue_name.length
// where the queue_name is the name of the queue
This function does not require a parameter.
The queue.length
function returns the number of elements in the queue and is used to get the current size of the queue.
The code below shows how to use the queue.length
function in Dart.
import 'dart:convert';import 'dart:collection';void main() {Queue<int> queue_1 = new Queue<int>();queue_1.add(1);queue_1.add(3);queue_1.add(5);queue_1.add(2);queue_1.add(0);//Queue filled= 1->3->5->2->0print("queue_1 length: ${queue_1.length}");//Queue emptyQueue<int> queue_2 = new Queue<int>();print("queue_2 length: ${queue_2.length}");}