Add a diagnostic message for malformed imports in analyze.dart (#38355)


diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart
index f4a703c..adcbc2f 100644
--- a/dev/bots/analyze.dart
+++ b/dev/bots/analyze.dart
@@ -435,6 +435,22 @@
       );
     }
   }
+
+  for (final String key in dependencyMap.keys) {
+    for (final String dependency in dependencyMap[key]) {
+      if (dependencyMap[dependency] != null)
+        continue;
+      // Sanity check before performing _deepSearch, to ensure there's no rogue
+      // dependencies.
+      final String validFilenames = dependencyMap.keys.map((String name) => name + '.dart').join(', ');
+      errors.add(
+        '$key imported package:flutter/$dependency.dart '
+        'which is not one of the valid exports { $validFilenames }.\n'
+        'Consider changing $dependency.dart to one of them.'
+      );
+    }
+  }
+
   for (final String package in dependencyMap.keys) {
     final List<String> loop = _deepSearch<String>(dependencyMap, package);
     if (loop != null) {
@@ -1180,6 +1196,9 @@
 }
 
 List<T> _deepSearch<T>(Map<T, Set<T>> map, T start, [ Set<T> seen ]) {
+  if (map[start] == null)
+    return null; // We catch these separately.
+
   for (final T key in map[start]) {
     if (key == start)
       continue; // we catch these separately