Dart String Manipulations: Strings contains()

Jeet BhaluJeet Bhalu
1 min read

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
0
Subscribe to my newsletter

Read articles from Jeet Bhalu directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Jeet Bhalu
Jeet Bhalu

i am Jeet Bhalu i am flutter App developer