void main(){
  // Creating list languages
  List languages = new List();
  // Adding items to the list
  languages.add('Dart');
  languages.add('Python');
  languages.add('Java');
  languages.add('C#');
  languages.add('C++');
  // Print result
  print(languages);   
 // iterate through the list
 // Returns the first item whose length is greater than 3
  var val = languages.firstWhere((item) => item.length > 3, orElse: () => null);
  // if val is null, then the if statement is executed
  if ( null == val ) {
    print('Language not found.');
  }
  // Display result
  print(val);  
  // Creating another list
  List<String> fruits = ['Apple', 'Lemon', 'Avocado', 'Orange'];
  // iterate through the list
 // Returns the first item that contains PineApple
 // the orElse() is invoke if not found
  var fav = fruits.firstWhere((item) => item.contains('PineApple'), 
      orElse: () => 'Fruit not available');
  print(fav);
 }Output
 [Dart, Python, Java, C#, C++]
 Dart
 Fruit not available
I’m Abhishek, a DevOps, SRE, DevSecOps, and Cloud expert with a passion for sharing knowledge and real-world experiences. I’ve had the opportunity to work with Cotocus and continue to contribute to multiple platforms where I share insights across different domains:
- 
DevOps School – Tech blogs and tutorials 
- 
Holiday Landmark – Travel stories and guides 
- 
Stocks Mantra – Stock market strategies and tips 
- 
My Medic Plus – Health and fitness guidance 
- 
TrueReviewNow – Honest product reviews 
- 
Wizbrand – SEO and digital tools for businesses 
I’m also exploring the fascinating world of Quantum Computing.