by @kodeazy
flutter How to remove elements in a list based on specific condition in dart file?
- In this blog we will discuss on how to remove elements from a
List
in dart file based on specific condition. removeWhere
function is used to remove the elements from theList
based on the given condition.- Below is the example program to check and remove the elements from the list where number is lesser than
3
.
void main() {
List<int> exampleArray = [1, 2, 3, 4];
exampleArray.removeWhere((item) => item < 3);
print(exampleArray);
}
Output:
[3, 4]