diff --git a/packages/flutter_tools/lib/src/commands/create_base.dart b/packages/flutter_tools/lib/src/commands/create_base.dart index 90c3fa00bbb8..36e84c40f4d1 100644 --- a/packages/flutter_tools/lib/src/commands/create_base.dart +++ b/packages/flutter_tools/lib/src/commands/create_base.dart @@ -389,7 +389,7 @@ abstract class CreateBase extends FlutterCommand { 'macosIdentifier': appleIdentifier, 'linuxIdentifier': linuxIdentifier, 'windowsIdentifier': windowsIdentifier, - 'description': projectDescription, + 'description': projectDescription != null ? escapeYamlString(projectDescription) : null, 'dartSdk': '$flutterRoot/bin/cache/dart-sdk', 'androidMinApiLevel': android_common.minApiLevel, 'androidSdkVersion': kAndroidSdkMinVersion, diff --git a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart index 9069a3535174..1663f8cdaf2e 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -3266,6 +3266,24 @@ void main() { ), }); + testUsingContext('should escape ":" in project description', () async { + await _createProject( + projectDir, + [ + '--no-pub', + '--description', + 'a: b', + ], + [ + 'pubspec.yaml', + ], + ); + + final String rawPubspec = await projectDir.childFile('pubspec.yaml').readAsString(); + final Pubspec pubspec = Pubspec.parse(rawPubspec); + expect(pubspec.description, 'a: b'); + }); + testUsingContext('create an FFI plugin with ios, then add macos', () async { Cache.flutterRoot = '../..';