Dart Programming - Map.forEach() Function



Applies the specified function on every Map entry. In other words, forEach enables iterating through the Maps entries.

Syntax

 Map.forEach(void f(K key, V value)); 

Parameters

  • f(K key, V value) − Applies f to each key-value pair of the map.

    Calling f must not add or remove keys from the map

Return Type − void.

Example

 void main() { var usrMap = {"name": "Tom", 'Email': 'tom@xyz.com'}; usrMap.forEach((k,v) => print('${k}: ${v}')); } 

It will produce the following output

 name: Tom Email: tom@xyz.com 
dart_programming_map.htm
Advertisements