diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart index 8efcc8c40b..2657e92542 100644 --- a/packages/flutter_tools/lib/src/devfs.dart +++ b/packages/flutter_tools/lib/src/devfs.dart @@ -622,11 +622,15 @@ class DevFS { final String packagePath = fs.path.fromUri(packageUri); final Directory packageDirectory = fs.directory(packageUri); Uri directoryUriOnDevice = fs.path.toUri(fs.path.join('packages', packageName) + fs.path.separator); - bool packageExists; + bool packageExists = packageDirectory.existsSync(); + + if (!packageExists) { + // If the package directory doesn't exist at all, we ignore it. + continue; + } if (fs.path.isWithin(rootDirectory.path, packagePath)) { // We already scanned everything under the root directory. - packageExists = packageDirectory.existsSync(); directoryUriOnDevice = fs.path.toUri( fs.path.relative(packagePath, from: rootDirectory.path) + fs.path.separator );