Skip to content

Map should have a getter for its key/value pairs #7088

Closed
@DartBot

Description

@DartBot

This issue was originally filed by @seaneagan


Map should have something like:

/// a live view of the [:Pair:]s contained in this Map
Set<Pair<K, V>> get pairs;

...and a corresponding constructor:

Map.fromPairs(Iterable<Pair<K, V>> pairs);

where Pair is just:

class Pair<K, V> {
  const Pair(this.key, this.value);
  final K key;
  final V value;
}

Examples:

print(map.pairs.mappedBy((pair) => "${pair.key} -> ${pair.value}").join(", "));

var nonNullMap = new Map.fromPairs(map.pairs.where((pair) => pair.value != null));

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.core-2type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions