Dart String Manipulations: Strings contains()

Dart String Manipulations: Strings contains()

contains:

  • The contains method is used to check if a given element is present in a list. It takes one argument, which is the element to be searched for in the list. If the element is found in the list, the method returns true.Otherwise, it returns false.

Example:

void main() {
  var fruits = ['apple', 'banana', 'orange'];
  print(fruits.contains('banana')); // Output: true
  print(fruits.contains('grape'));
  print(fruits.contains('apple')); // Output: false
}

Output:

true
false
true