From 20bc0a9cb8df861c2032bca5efd704b2b0b0f74e Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Thu, 26 Sep 2024 10:04:03 -0700 Subject: [PATCH] Fix line-wrapping in `flutter create` error message. (#150325) --- .../lib/src/commands/create_base.dart | 19 +++++++++---------- .../commands.shard/permeable/create_test.dart | 12 +++++++++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/create_base.dart b/packages/flutter_tools/lib/src/commands/create_base.dart index 70413d51125..7ae2d59967f 100644 --- a/packages/flutter_tools/lib/src/commands/create_base.dart +++ b/packages/flutter_tools/lib/src/commands/create_base.dart @@ -857,16 +857,15 @@ String? potentialValidPackageName(String name){ String? _validateProjectName(String projectName) { if (!isValidPackageName(projectName)) { final String? potentialValidName = potentialValidPackageName(projectName); - - return [ - '"$projectName" is not a valid Dart package name.', - '\n\n', - 'The name should be all lowercase, with underscores to separate words, "just_like_this".', - 'Use only basic Latin letters and Arabic digits: [a-z0-9_].', - "Also, make sure the name is a valid Dart identifier—that it doesn't start with digits and isn't a reserved word.\n", - 'See https://dart.dev/tools/pub/pubspec#name for more information.', - if (potentialValidName != null) '\nTry "$potentialValidName" instead.', - ].join(); + return '"$projectName" is not a valid Dart package name.' + '${ potentialValidName != null ? ' Try "$potentialValidName" instead.' : '' }\n' + '\n' + 'The name should consist of lowercase words separated by underscores, "like_this". ' + 'Use only basic Latin letters and Arabic digits: [a-z0-9_], and ' + 'ensure the name is a valid Dart identifier ' + '(i.e. it does not start with a digit and is not a reserved word).\n' + '\n' + 'See https://dart.dev/tools/pub/pubspec#name for more information.'; } if (_packageDependencies.contains(projectName)) { return "Invalid project name: '$projectName' - this will conflict with Flutter " 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 3cc6e62dc49..391c51fd6bc 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -838,9 +838,15 @@ void main() { ['--no-pub', '--template=plugin', '--project-name', 'xyz-xyz', '--platforms', 'android,ios',], [], ), - allOf( - throwsToolExit(message: '"xyz-xyz" is not a valid Dart package name.'), - throwsToolExit(message: 'Try "xyz_xyz" instead.'), + throwsToolExit(message: + '"xyz-xyz" is not a valid Dart package name. Try "xyz_xyz" instead.\n' + '\n' + 'The name should consist of lowercase words separated by underscores, ' + '"like_this". Use only basic Latin letters and Arabic digits: [a-z0-9_], ' + 'and ensure the name is a valid Dart identifier (i.e. it does not start ' + 'with a digit and is not a reserved word).\n' + '\n' + 'See https://dart.dev/tools/pub/pubspec#name for more information.' ), ); });