Cherry-picks (#36507) https://github.com/flutter/engine/pull/9935 Fix backspace crash on Chinese devices https://github.com/flutter/flutter/pull/36105 Catch a yaml parse failure during project creation
diff --git a/bin/internal/engine.version b/bin/internal/engine.version index 6f23bd0..6ec30b3 100644 --- a/bin/internal/engine.version +++ b/bin/internal/engine.version
@@ -1 +1 @@ -bb08b06d137a329ed1fa63471d7209c313ebd196 +fee001c93f25a1e7258e762781a7361f122d29f5
diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index ef4a38d..16f5f0c 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart
@@ -15,6 +15,7 @@ import 'cache.dart'; import 'desktop.dart'; import 'flutter_manifest.dart'; +import 'globals.dart'; import 'ios/ios_workflow.dart'; import 'ios/plist_utils.dart' as plist; import 'ios/xcodeproj.dart' as xcode; @@ -164,9 +165,16 @@ /// Completes with an empty [FlutterManifest], if the file does not exist. /// Completes with a ToolExit on validation error. static FlutterManifest _readManifest(String path) { - final FlutterManifest manifest = FlutterManifest.createFromPath(path); - if (manifest == null) + FlutterManifest manifest; + try { + manifest = FlutterManifest.createFromPath(path); + } on YamlException catch (e) { + printStatus('Error detected in pubspec.yaml:', emphasis: true); + printError('$e'); + } + if (manifest == null) { throwToolExit('Please correct the pubspec.yaml file at $path'); + } return manifest; }
diff --git a/packages/flutter_tools/test/project_test.dart b/packages/flutter_tools/test/project_test.dart index 6273421..a5f23e0 100644 --- a/packages/flutter_tools/test/project_test.dart +++ b/packages/flutter_tools/test/project_test.dart
@@ -40,7 +40,19 @@ expect( () => FlutterProject.fromDirectory(directory), - throwsA(isInstanceOf<Exception>()), + throwsA(isInstanceOf<ToolExit>()), + ); + }); + + testInMemory('fails on pubspec.yaml parse failure', () async { + final Directory directory = fs.directory('myproject'); + directory.childFile('pubspec.yaml') + ..createSync(recursive: true) + ..writeAsStringSync(parseErrorPubspec); + + expect( + () => FlutterProject.fromDirectory(directory), + throwsA(isInstanceOf<ToolExit>()), ); }); @@ -52,7 +64,7 @@ expect( () => FlutterProject.fromDirectory(directory), - throwsA(isInstanceOf<Exception>()), + throwsA(isInstanceOf<ToolExit>()), ); }); @@ -575,6 +587,14 @@ invalid: '''; +String get parseErrorPubspec => ''' +name: hello +# Whitespace is important. +flutter: + something: + something_else: +'''; + String projectFileWithBundleId(String id, {String qualifier}) { return ''' 97C147061CF9000F007C117D /* Debug */ = {