The `contains` method in Dart checks if the collection contains an element equal to the specified element.
The syntax of Runes.contains() method is:
bool contains(Object element)
This contains() method of Runes returns true if the collection contains an element equal to element
.
Parameter | Optional/Required | Description |
---|---|---|
element | required | The element to check for in the collection. |
Runes.contains() returns value of type bool
.
In this example,
runes
from the string 'Hello'.contains
method to check if the sequence contains the Unicode code point for 'e'.void main() {
Runes runes = Runes('Hello');
bool containsE = runes.contains(101);
print('Does sequence contain the Unicode code point for \'e\'? $containsE');
}
Does sequence contain the Unicode code point for 'e'? true
In this example,
emojis
from the string '👋🏽🚀🌟'.contains
method to check if the sequence contains the Unicode code point for rocket emoji.void main() {
Runes emojis = Runes('👋🏽🚀🌟');
bool containsRocket = emojis.contains(127937);
print('Does emoji sequence contain the Unicode code point for rocket? $containsRocket');
}
Does emoji sequence contain the Unicode code point for rocket? true
In this example,
numbers
from the string '12345'.contains
method to check if the sequence contains the Unicode code point for '3'.void main() {
Runes numbers = Runes('12345');
bool containsThree = numbers.contains(51);
print('Does number sequence contain the Unicode code point for \'3\'? $containsThree');
}
Does number sequence contain the Unicode code point for '3'? true
In this Dart tutorial, we learned about contains() method of Runes: the syntax and few working examples with output and detailed explanation for each example.