diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index 0789ec7454..b68c8fd002 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -294,8 +294,9 @@ class CreateCommand extends CreateBase { if (!creatingNewProject && requestedPlatforms.isNotEmpty) { _printPluginUpdatePubspecMessage(relativePluginPath, platformsString); } else if (_getSupportedPlatformsInPlugin(projectDir).isEmpty){ - globals.printError(_kNoPlatformsArgMessage); + _printNoPluginMessage(); } + _printAddPlatformMessage(relativePluginPath); } else { // Tell the user the next steps. final FlutterProject project = FlutterProject.fromPath(projectDirPath); @@ -489,15 +490,22 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi void _printPluginUpdatePubspecMessage(String pluginPath, String platformsString) { globals.printStatus(''' - You need to update $pluginPath/pubspec.yaml to support $platformsString. -For more information, see https://flutter.dev/go/developing-plugins. ''', emphasis: true, color: TerminalColor.red); } -const String _kNoPlatformsArgMessage = ''' +void _printNoPluginMessage() { + globals.printError(''' +You've created a plugin project that doesn't yet support any platforms. -Must specify at least one platform using --platforms. -For more information, see https://flutter.dev/go/developing-plugins. -'''; +'''); +} + +void _printAddPlatformMessage(String pluginPath) { + globals.printStatus(''' +To add platforms, run `flutter create -t plugin --platforms .` under $pluginPath. +For more information, see https://flutter.dev/go/plugin-platforms. + +'''); +} 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 d889368d2a..3dfe88961f 100755 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -32,7 +32,7 @@ import '../../src/context.dart'; import '../../src/pubspec_schema.dart'; import '../../src/testbed.dart'; -const String _kNoPlatformsMessage = 'Must specify at least one platform using --platforms.\n'; +const String _kNoPlatformsMessage = 'You\'ve created a plugin project that doesn\'t yet support any platforms.\n'; const String frameworkRevision = '12345678'; const String frameworkChannel = 'omega'; // TODO(fujino): replace FakePlatform.fromPlatform() with FakePlatform() @@ -2315,6 +2315,8 @@ void main() { await runner.run(['create', '--no-pub', '--template=plugin', projectDir.path]); expect(logger.errorText, contains(_kNoPlatformsMessage)); + expect(logger.statusText, contains('To add platforms, run `flutter create -t plugin --platforms .` under ${globals.fs.path.normalize(globals.fs.path.relative(projectDir.path))}.')); + expect(logger.statusText, contains('For more information, see https://flutter.dev/go/plugin-platforms.')); }, overrides: { FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false),