What is Map.forEach() in Dart?
Map.forEach()
The Dart method forEach() is used to iterate over the entries of the Map.
Syntax
Map.forEach(void f(K key, V value));
Parameters
- The
forEach()method requires akeyand avalue. It appliesfto each key-value pair of the map.
Code
The following code illustrates how to use the forEach() method in Dart.
void main() {var map = {"title": "Map.forEach()", 'language': 'Dart', 'platform': 'Educative.io'};// iterating using forEach()map.forEach((k,v) => print('${k}: ${v}'));}