Skip to content

Commit 20bc0a9

Browse files
authored
Fix line-wrapping in flutter create error message. (#150325)
1 parent a0e75cd commit 20bc0a9

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

packages/flutter_tools/lib/src/commands/create_base.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -857,16 +857,15 @@ String? potentialValidPackageName(String name){
857857
String? _validateProjectName(String projectName) {
858858
if (!isValidPackageName(projectName)) {
859859
final String? potentialValidName = potentialValidPackageName(projectName);
860-
861-
return <String>[
862-
'"$projectName" is not a valid Dart package name.',
863-
'\n\n',
864-
'The name should be all lowercase, with underscores to separate words, "just_like_this".',
865-
'Use only basic Latin letters and Arabic digits: [a-z0-9_].',
866-
"Also, make sure the name is a valid Dart identifier—that it doesn't start with digits and isn't a reserved word.\n",
867-
'See https://dart.dev/tools/pub/pubspec#name for more information.',
868-
if (potentialValidName != null) '\nTry "$potentialValidName" instead.',
869-
].join();
860+
return '"$projectName" is not a valid Dart package name.'
861+
'${ potentialValidName != null ? ' Try "$potentialValidName" instead.' : '' }\n'
862+
'\n'
863+
'The name should consist of lowercase words separated by underscores, "like_this". '
864+
'Use only basic Latin letters and Arabic digits: [a-z0-9_], and '
865+
'ensure the name is a valid Dart identifier '
866+
'(i.e. it does not start with a digit and is not a reserved word).\n'
867+
'\n'
868+
'See https://dart.dev/tools/pub/pubspec#name for more information.';
870869
}
871870
if (_packageDependencies.contains(projectName)) {
872871
return "Invalid project name: '$projectName' - this will conflict with Flutter "

packages/flutter_tools/test/commands.shard/permeable/create_test.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,15 @@ void main() {
838838
<String>['--no-pub', '--template=plugin', '--project-name', 'xyz-xyz', '--platforms', 'android,ios',],
839839
<String>[],
840840
),
841-
allOf(
842-
throwsToolExit(message: '"xyz-xyz" is not a valid Dart package name.'),
843-
throwsToolExit(message: 'Try "xyz_xyz" instead.'),
841+
throwsToolExit(message:
842+
'"xyz-xyz" is not a valid Dart package name. Try "xyz_xyz" instead.\n'
843+
'\n'
844+
'The name should consist of lowercase words separated by underscores, '
845+
'"like_this". Use only basic Latin letters and Arabic digits: [a-z0-9_], '
846+
'and ensure the name is a valid Dart identifier (i.e. it does not start '
847+
'with a digit and is not a reserved word).\n'
848+
'\n'
849+
'See https://dart.dev/tools/pub/pubspec#name for more information.'
844850
),
845851
);
846852
});

0 commit comments

Comments
 (0)