Stop using deprecated mapMap from pkg:collection (#2544)

For now, copy the implementation locally
diff --git a/lib/src/command/list_package_dirs.dart b/lib/src/command/list_package_dirs.dart
index c3b14f1..75a23cb 100644
--- a/lib/src/command/list_package_dirs.dart
+++ b/lib/src/command/list_package_dirs.dart
@@ -2,7 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-import 'package:collection/collection.dart';
 import 'package:path/path.dart' as p;
 
 import '../command.dart';
diff --git a/lib/src/lock_file.dart b/lib/src/lock_file.dart
index 21a032f..da677d0 100644
--- a/lib/src/lock_file.dart
+++ b/lib/src/lock_file.dart
@@ -5,7 +5,7 @@
 import 'dart:collection';
 import 'dart:convert';
 
-import 'package:collection/collection.dart';
+import 'package:collection/collection.dart' hide mapMap;
 // ignore: deprecated_member_use
 import 'package:package_config/packages_file.dart' as packages_file;
 import 'package:path/path.dart' as p;
diff --git a/lib/src/package_graph.dart b/lib/src/package_graph.dart
index 66086d0..35b06a5 100644
--- a/lib/src/package_graph.dart
+++ b/lib/src/package_graph.dart
@@ -2,13 +2,14 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-import 'package:collection/collection.dart';
+import 'package:collection/collection.dart' hide mapMap;
 
 import 'entrypoint.dart';
 import 'lock_file.dart';
 import 'package.dart';
 import 'solver.dart';
 import 'source/cached.dart';
+import 'utils.dart';
 
 /// A holistic view of the entire transitive dependency graph for an entrypoint.
 class PackageGraph {
diff --git a/lib/src/pubspec.dart b/lib/src/pubspec.dart
index 080358e..8bcc3a9 100644
--- a/lib/src/pubspec.dart
+++ b/lib/src/pubspec.dart
@@ -4,7 +4,7 @@
 
 import 'dart:io';
 
-import 'package:collection/collection.dart';
+import 'package:collection/collection.dart' hide mapMap;
 import 'package:meta/meta.dart';
 import 'package:path/path.dart' as path;
 import 'package:pub_semver/pub_semver.dart';
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 184bcf5..2973b4d 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -613,3 +613,21 @@
     version1.major == version2.major &&
     version1.minor == version2.minor &&
     version1.patch == version2.patch;
+
+/// Creates a new map from [map] with new keys and values.
+///
+/// The return values of [key] are used as the keys and the return values of
+/// [value] are used as the values for the new map.
+Map<K2, V2> mapMap<K1, V1, K2, V2>(
+  Map<K1, V1> map, {
+  K2 Function(K1, V1) key,
+  V2 Function(K1, V1) value,
+}) {
+  key ??= (mapKey, _) => mapKey as K2;
+  value ??= (_, mapValue) => mapValue as V2;
+
+  return <K2, V2>{
+    for (var entry in map.entries)
+      key(entry.key, entry.value): value(entry.key, entry.value),
+  };
+}