Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

dart
communitycreator

What is List remove() in Dart?

Maria Elijah

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The method remove() removes an item from a List by its value.

The List.remove() method removes the first occurrence of the specified item in the list.

Syntax

List_name.remove(Object value);

List_name is the name of the list.

Parameter

  • value: This specifies the value of the item that should be removed from the list.

Return value

The remove() method returns true if the specified value is removed from the list.

Code

The following code shows how to use the List remove() method in dart:

void main() {
// Creating list
List myList = [1,2,3,2,5,6,7,8,9];
//Display result
print('The list before removing the element from the list: ${myList}');
bool res = myList.remove(2);
print('The new list after removing the element from the list: ${myList}');
}

Note: The value 2 occurred twice in the list. The method remove() will remove the first occurrence of the item to be removed from the list.

RELATED TAGS

dart
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring