.length
Anonymous contributor
Published Apr 4, 2024Updated May 15, 2024
Contribute to Docs
In Dart, the .length
property returns the number of elements in a queue.
Syntax
queueName.length
queueName
: The name of the queue to be checked.
Example
The below example creates a queue named example_queue
, appends five integer elements to it, and calculates its length using the .length
property:
import 'dart:convert';import 'dart:collection';void main(){// Initializing a queueQueue<int> example_queue = Queue<int>();// Appending elements to the queueexample_queue.addAll([1, 3, 5, 2, 0]);// Calculating the length of the queueprint("The length of the queue is: ${example_queue.length}");}
The above code will give the following output:
The length of the queue is: 5
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.