diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart
index ea41b90facc506236628aec51c1e1cafa885c45f..fc057731b1ecf3a44e65024f628b540b4523e8e5 100644
--- a/packages/flutter_tools/lib/src/test/flutter_platform.dart
+++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart
@@ -285,8 +285,12 @@ class _Compiler {
   }
 
   Future<dynamic> shutdown() async {
-    await compiler.shutdown();
-    compiler = null;
+    // Check for null in case this instance is shut down before the
+    // lazily-created compiler has been created.
+    if (compiler != null) {
+      await compiler.shutdown();
+      compiler = null;
+    }
   }
 
   static Future<T> handleTimeout<T>(Future<T> value, String path) {