From c8305f77e01b4bddade00c8bcda618c184725fff Mon Sep 17 00:00:00 2001 From: abdultalha0862 <20211a0405@bvrit.ac.in> Date: Wed, 25 Feb 2026 07:17:48 +0000 Subject: [PATCH 1/3] Add docs for Dart .removeFirst() --- .../queue/terms/removeFirst/removeFirst.md | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 content/dart/concepts/queue/terms/removeFirst/removeFirst.md diff --git a/content/dart/concepts/queue/terms/removeFirst/removeFirst.md b/content/dart/concepts/queue/terms/removeFirst/removeFirst.md new file mode 100644 index 00000000000..206d7f11270 --- /dev/null +++ b/content/dart/concepts/queue/terms/removeFirst/removeFirst.md @@ -0,0 +1,55 @@ +--- +Title: '.removeFirst()' +Description: 'Removes and returns the first element from a queue.' +Subjects: + - 'Code Foundations' + - 'Computer Science' +Tags: + - 'Dart' + - 'Methods' + - 'Queues' +CatalogContent: + - 'learn-dart' + - 'paths/computer-science' +--- + +The **`.removeFirst()`** method in Dart is used to remove and return the first element from a queue if it exists. + +## Syntax + +```pseudo +E removeFirst() +``` + +- `E`: The type of elements in the queue. + +## Example + +In the following example, the first element is removed from the queue using the `.removeFirst()` method: + +```dart +import 'dart:collection'; + +void main() { + // Creating a queue + Queue queue = Queue.from([1, 2, 3, 4, 5]); + + // Outputting the original queue + print('Original Queue: $queue'); + + // Removing the first element from the queue + int removedElement = queue.removeFirst(); + print('Removed Element: $removedElement'); + + // Outputting the modified queue + print('Modified Queue: $queue'); +} +``` + +The above code results in the following output: + +```shell +Original Queue: {1, 2, 3, 4, 5} +Removed Element: 1 +Modified Queue: {2, 3, 4, 5} +``` From 228128f58c2f12e992c949deb58f639aee843f21 Mon Sep 17 00:00:00 2001 From: abdultalha0862 <20211a0405@bvrit.ac.in> Date: Wed, 25 Feb 2026 09:03:57 +0000 Subject: [PATCH 2/3] Updated docs of Dart .removeFirst() method --- content/dart/concepts/queue/terms/removeFirst/removeFirst.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/dart/concepts/queue/terms/removeFirst/removeFirst.md b/content/dart/concepts/queue/terms/removeFirst/removeFirst.md index 206d7f11270..278a3219920 100644 --- a/content/dart/concepts/queue/terms/removeFirst/removeFirst.md +++ b/content/dart/concepts/queue/terms/removeFirst/removeFirst.md @@ -13,7 +13,7 @@ CatalogContent: - 'paths/computer-science' --- -The **`.removeFirst()`** method in Dart is used to remove and return the first element from a queue if it exists. +The **`.removeFirst()`** method in Dart is used to remove and return the first element from a queue. ## Syntax @@ -23,6 +23,8 @@ E removeFirst() - `E`: The type of elements in the queue. +**Note:** Calling this method on an empty queue will throw a `StateError`. + ## Example In the following example, the first element is removed from the queue using the `.removeFirst()` method: From e0f76dee40f74b8162dba51bf295bd81822b562a Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Thu, 26 Feb 2026 11:59:52 +0530 Subject: [PATCH 3/3] Revise .removeFirst() method documentation Updated the documentation for the .removeFirst() method to clarify parameters and return value. --- .../queue/terms/removeFirst/removeFirst.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/content/dart/concepts/queue/terms/removeFirst/removeFirst.md b/content/dart/concepts/queue/terms/removeFirst/removeFirst.md index 278a3219920..9898268fc40 100644 --- a/content/dart/concepts/queue/terms/removeFirst/removeFirst.md +++ b/content/dart/concepts/queue/terms/removeFirst/removeFirst.md @@ -13,7 +13,7 @@ CatalogContent: - 'paths/computer-science' --- -The **`.removeFirst()`** method in Dart is used to remove and return the first element from a queue. +The **`.removeFirst()`** method in Dart is used to remove and return the first element from a `Queue`. ## Syntax @@ -21,9 +21,15 @@ The **`.removeFirst()`** method in Dart is used to remove and return the first e E removeFirst() ``` -- `E`: The type of elements in the queue. +**Parameters:** -**Note:** Calling this method on an empty queue will throw a `StateError`. +None. + +**Return value:** + +This method returns the first element (`E`) in the queue. + +> **Note:** Calling this method on an empty queue will throw a `StateError`. ## Example @@ -36,14 +42,14 @@ void main() { // Creating a queue Queue queue = Queue.from([1, 2, 3, 4, 5]); - // Outputting the original queue + // Print the original queue print('Original Queue: $queue'); - // Removing the first element from the queue + // Remove the first element int removedElement = queue.removeFirst(); print('Removed Element: $removedElement'); - // Outputting the modified queue + // Print the modified queue print('Modified Queue: $queue'); } ```