.containsValue()
Anonymous contributor
Published Jul 12, 2024
Contribute to Docs
In Dart, the .containsValue()
method is used to check if a particular value is present in a Map
. If the value exists, the method returns true
. Otherwise, it returns false
.
Syntax
newMap.containsValue(val)
newMap
: TheMap
to be checked.val
: The value to be searched for.
Example
The following example demonstrates the usage of the .containsValue()
method:
void main() {// Creating a MapMap newMap = {1: 'Cricket', 2: 'Football', 3: 'Tennis'};// Checking if 'Tennis' exists in the Mapprint(newMap.containsValue('Tennis'));}
The above code produces the following output:
true
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.