Dart| Flutter How to check element exists in Array

This tutorial shows how to check element exists in array or list Dart or Flutter List

How to check sublist exists in a list of  Dart and Flutter

In dart, Array and List stores the same type of collections, Arrays are fixed, List are dynamic in nature.

Let’s see how to check an element exists in array or list

How do Check value exist in a Array or List of dart/flutter?

dart list provides multiple ways to check the sub list contains in the list of elements.

First Convert list into set using Set.of() method Check sub list exists in Set using Set.containsAll() method

Here is an example code

void main() {
  List<int> array = [1, 4, 5, 2, 8];

  print(array.contains(2)); // true
  print(array.contains(21)); // false
void main() {
  List<String> array = ["one", "two", "three"];

  print(array.contains("one"));// true
  print(array.contains("four")); // false
  • use indexOf
void main() {
  List<String> array = ["one", "two", "three"];

  print(array.indexOf("one") >= 0); // true, 
  print(array.indexOf("four") >= 0); // false,


To summarize, Learn how to check the sublist contains all elements in a list dart and flutter.

Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
You'll get a notification every time a post gets published here.

Related posts

Dart| Flutter How to: Read pubspec.yaml attributes (version) with examples

How to Create and build a Singleton Class Dart or Flutter example| Dart By Example

What is the difference between var and dynamic and final in dart?| Flutter By Example

How to: Check if Phone number is valid or not in Dart| Flutter By Example

Dart| Flutter How to read an image from a disk and resize a file

Dart/Flutter: How to write setter and getter fields or members variables in a class with Example

Dart| Flutter How to get extension name and MIME type of a file with example