Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:core
  3. Map<K,V>
  4. Map.fromEntries factory constructor
Map.fromEntries
description

Map<K,V>.fromEntries constructor

Map<K,V>.fromEntries(
  1. Iterable<MapEntry<K,V>>entries
)

Creates a new map and adds all entries.

Returns a newMap<K, V> where all entries ofentrieshave been added in iteration order.

If multipleentries have the same key,later occurrences overwrite the value of the earlier ones.

Equivalent to the map literal:

<K, V>{for (var e in entries) e.key: e.value}

Example:

final moonCount = <String, int>{'Mercury': 0, 'Venus': 0, 'Earth': 1,  'Mars': 2, 'Jupiter': 79, 'Saturn': 82, 'Uranus': 27, 'Neptune': 14};final map = Map.fromEntries(moonCount.entries);

Implementation

factory Map.fromEntries(Iterable<MapEntry<K, V>> entries) =>    <K, V>{}..addEntries(entries);
  1. Dart
  2. dart:core
  3. Map<K,V>
  4. Map.fromEntries factory constructor
Map class

[8]ページ先頭

©2009-2025 Movatter.jp