Catch any FileSystemException thrown when trying to read the template manifest during flutter create (#145620)

Fixes https://github.com/flutter/flutter/issues/145423
This commit is contained in:
Andrew Kolos
2024-04-26 14:24:25 -07:00
committed by GitHub
parent cc9ac7d13c
commit 69e68f6e04
2 changed files with 46 additions and 1 deletions

View File

@@ -669,8 +669,18 @@ abstract class CreateBase extends FlutterCommand {
'templates',
'template_manifest.json',
);
final String manifestFileContents;
try {
manifestFileContents = globals.fs.file(manifestPath).readAsStringSync();
} on FileSystemException catch (e) {
throwToolExit(
'Unable to read the template manifest at path "$manifestPath".\n'
'Make sure that your user account has sufficient permissions to read this file.\n'
'Exception details: $e',
);
}
final Map<String, Object?> manifest = json.decode(
globals.fs.file(manifestPath).readAsStringSync(),
manifestFileContents,
) as Map<String, Object?>;
return Set<Uri>.from(
(manifest['files']! as List<Object?>).cast<String>().map<Uri>(