Reland: More verification on flutter build web, add tests and cleanup (#34173)

diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart
index 2ea276e..ef4a38d 100644
--- a/packages/flutter_tools/lib/src/project.dart
+++ b/packages/flutter_tools/lib/src/project.dart
@@ -580,11 +580,14 @@
 
   /// Whether this flutter project has a web sub-project.
   bool existsSync() {
-    return parent.directory.childDirectory('web').existsSync();
+    return parent.directory.childDirectory('web').existsSync()
+      && indexFile.existsSync();
   }
 
   /// The html file used to host the flutter web application.
-  File get indexFile => parent.directory.childDirectory('web').childFile('index.html');
+  File get indexFile => parent.directory
+      .childDirectory('web')
+      .childFile('index.html');
 
   Future<void> ensureReadyForPlatformSpecificTooling() async {}
 }