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: Find a Given String is numeric or not

How to iterate loop Enum in Dart | Get Enum with index in Flutter By Example

Dart Enum comparison operator| Enum compareByIndex example| Flutter By Example

Dart tutorial examples/ Flutter By Examples

How to add Methods or Values to Enums in Dart | Flutter By Example

How to convert Double to Integer or Integer to double in Dart| Flutter By Example

How to: Enum to String in Dart | Print Enum name as String in Flutter By Example