.add()
Anonymous contributor
Published Apr 13, 2024
Contribute to Docs
In Dart, the .add()
method is used to insert a specified element to the end of a queue. This method is part of the Queue
class under the dart:collection
library.
Syntax
queue.add(element);
queue
: The name of the queue to which a value is to be inserted.element
: The value to be inserted.
Example
The following example demonstrates the usage of the .add()
method:
import 'dart:collection';void main() {Queue values = new Queue();values.add(12);values.add(24);values.add(36);values.add(48);for(var num in values) {print(num);}}
The output for the above code is as follows:
12243648
All contributors
- Anonymous contributor
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.