From 2d61b1ea5943adf9b5c842168a127ac44c730639 Mon Sep 17 00:00:00 2001 From: AlexanderKauth <129531632+AlexanderKauth@users.noreply.github.com> Date: Mon, 26 Jan 2026 15:18:14 +0100 Subject: [PATCH 1/2] Add documentation for removeWhere() method in Dart This document explains the removeWhere() method for Dart Queues, including its syntax and usage with examples. --- .../queue/terms/removeWhere/removeWhere.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 content/dart/concepts/queue/terms/removeWhere/removeWhere.md diff --git a/content/dart/concepts/queue/terms/removeWhere/removeWhere.md b/content/dart/concepts/queue/terms/removeWhere/removeWhere.md new file mode 100644 index 00000000000..5efdd052ed1 --- /dev/null +++ b/content/dart/concepts/queue/terms/removeWhere/removeWhere.md @@ -0,0 +1,40 @@ +# removeWhere() +--- +Title: removeWhere() +Description: Removes elements from a Dart Queue based on a condition. +Subjects: + - Computer Science + - Dart +Tags: + - Queue + - Collection + - Methods +CatalogContent: + - Dart + - Data Structures +--- + +## Introduction +The `removeWhere()` method removes all elements from a `Queue` that satisfy +a given condition. The condition is defined using a callback function that +returns `true` for elements that should be removed from the queue. + +## Syntax +```dart +queue.removeWhere((element) => condition); + +import 'dart:collection'; + +void main() { + Queue tasks = Queue.from([ + 'write code', + 'review pull request', + 'fix bugs', + 'write tests' + ]); + + // Remove all tasks that contain the word 'write' + tasks.removeWhere((task) => task.contains('write')); + + print(tasks); // Output: [review pull request, fix bugs] +} From a077b01d67f8cf099cd16268bc2f563d52075ba2 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Tue, 27 Jan 2026 15:25:36 +0530 Subject: [PATCH 2/2] Revise removeWhere() documentation for clarity Updated the documentation for the removeWhere() method to clarify its functionality and improve formatting. --- .../queue/terms/removeWhere/removeWhere.md | 53 +++++++++++++------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/content/dart/concepts/queue/terms/removeWhere/removeWhere.md b/content/dart/concepts/queue/terms/removeWhere/removeWhere.md index 5efdd052ed1..cb7646ed175 100644 --- a/content/dart/concepts/queue/terms/removeWhere/removeWhere.md +++ b/content/dart/concepts/queue/terms/removeWhere/removeWhere.md @@ -1,28 +1,40 @@ -# removeWhere() --- -Title: removeWhere() -Description: Removes elements from a Dart Queue based on a condition. +Title: '.removeWhere()' +Description: 'Removes all elements from a queue that satisfy a given condition.' Subjects: - - Computer Science - - Dart + - 'Computer Science' + - 'Code Foundation' Tags: - - Queue - - Collection - - Methods + - 'Collection' + - 'Dart' + - 'Methods' + - 'Queues' CatalogContent: - - Dart - - Data Structures + - 'learn-dart' + - 'paths/computer-science' --- -## Introduction -The `removeWhere()` method removes all elements from a `Queue` that satisfy -a given condition. The condition is defined using a callback function that -returns `true` for elements that should be removed from the queue. +The **`.removeWhere()`** method removes all elements from a `Queue` that return `true` for a specified condition. The queue is modified in place. ## Syntax -```dart -queue.removeWhere((element) => condition); +```pseudo +queue.removeWhere(test) +``` + +**Parameters:** + +- `test` (bool Function(E element)): A function that returns `true` for elements that should be removed from the queue. + +**Return value:** + +This method returns `void`. The original queue is updated by removing all matching elements. + +## Example: Removing elements from a queue based on a condition + +In this example, `.removeWhere()` is used to remove all tasks from a queue that contain the word "write", updating the queue in place: + +```dart import 'dart:collection'; void main() { @@ -36,5 +48,12 @@ void main() { // Remove all tasks that contain the word 'write' tasks.removeWhere((task) => task.contains('write')); - print(tasks); // Output: [review pull request, fix bugs] + print(tasks); } +``` + +The output of this code is: + +```shell +{review pull request, fix bugs} +```