diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index f506a2f5cb..0923d70c3b 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -385,7 +385,7 @@ class CreateCommand extends CreateBase { 'main.dart', )); globals.printStatus('Your module code is in $relativeMainPath.'); - } else if (generateMethodChannelsPlugin) { + } else if (generateMethodChannelsPlugin || generateFfiPlugin) { final String relativePluginPath = globals.fs.path.normalize(globals.fs.path.relative(projectDirPath)); final List requestedPlatforms = _getUserRequestedPlatforms(); final String platformsString = requestedPlatforms.join(', '); @@ -400,7 +400,8 @@ class CreateCommand extends CreateBase { if (platformsToWarn.isNotEmpty) { _printWarningDisabledPlatform(platformsToWarn); } - _printPluginAddPlatformMessage(relativePluginPath); + final String template = generateMethodChannelsPlugin ? 'plugin' : 'plugin_ffi'; + _printPluginAddPlatformMessage(relativePluginPath, template); } else { // Tell the user the next steps. final FlutterProject project = FlutterProject.fromDirectory(globals.fs.directory(projectDirPath)); @@ -715,9 +716,9 @@ You've created a plugin project that doesn't yet support any platforms. '''); } -void _printPluginAddPlatformMessage(String pluginPath) { +void _printPluginAddPlatformMessage(String pluginPath, String template) { globals.printStatus(''' -To add platforms, run `flutter create -t plugin --platforms .` under $pluginPath. +To add platforms, run `flutter create -t $template --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 a09b4efbdb..e74ebf17c1 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -2740,6 +2740,22 @@ void main() { Logger: ()=> logger, }); + testUsingContext('created FFI plugin supports no platforms should print `no platforms` message', () async { + Cache.flutterRoot = '../..'; + + final CreateCommand command = CreateCommand(); + final CommandRunner runner = createTestCommandRunner(command); + + await runner.run(['create', '--no-pub', '--template=plugin_ffi', projectDir.path]); + expect(logger.errorText, contains(_kNoPlatformsMessage)); + expect(logger.statusText, contains('To add platforms, run `flutter create -t plugin_ffi --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(), + Logger: ()=> logger, + }); + testUsingContext('created plugin with no --platforms flag should not print `no platforms` message if the existing plugin supports a platform.', () async { Cache.flutterRoot = '../..';