Dart Programming – Map.forEach() Function

  • Post author:
  • Post category:Dart
  • Post comments:2 Comments
Dart Programming map.forEach() Function

In this guide, we will discuss Map.forEach() Function in Dart Programming Language. Applies the specified function on every Map entry. In other words, forEach enables iterating through the Map’s 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

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply