Skip to content

Commit e4bde83

Browse files
authored
plugin_ffi warn about lack of platform support (#106813)
1 parent 0df4885 commit e4bde83

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ class CreateCommand extends CreateBase {
385385
'main.dart',
386386
));
387387
globals.printStatus('Your module code is in $relativeMainPath.');
388-
} else if (generateMethodChannelsPlugin) {
388+
} else if (generateMethodChannelsPlugin || generateFfiPlugin) {
389389
final String relativePluginPath = globals.fs.path.normalize(globals.fs.path.relative(projectDirPath));
390390
final List<String> requestedPlatforms = _getUserRequestedPlatforms();
391391
final String platformsString = requestedPlatforms.join(', ');
@@ -400,7 +400,8 @@ class CreateCommand extends CreateBase {
400400
if (platformsToWarn.isNotEmpty) {
401401
_printWarningDisabledPlatform(platformsToWarn);
402402
}
403-
_printPluginAddPlatformMessage(relativePluginPath);
403+
final String template = generateMethodChannelsPlugin ? 'plugin' : 'plugin_ffi';
404+
_printPluginAddPlatformMessage(relativePluginPath, template);
404405
} else {
405406
// Tell the user the next steps.
406407
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.
715716
''');
716717
}
717718

718-
void _printPluginAddPlatformMessage(String pluginPath) {
719+
void _printPluginAddPlatformMessage(String pluginPath, String template) {
719720
globals.printStatus('''
720-
To add platforms, run `flutter create -t plugin --platforms <platforms> .` under $pluginPath.
721+
To add platforms, run `flutter create -t $template --platforms <platforms> .` under $pluginPath.
721722
For more information, see https://flutter.dev/go/plugin-platforms.
722723
723724
''');

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,6 +2740,22 @@ void main() {
27402740
Logger: ()=> logger,
27412741
});
27422742

2743+
testUsingContext('created FFI plugin supports no platforms should print `no platforms` message', () async {
2744+
Cache.flutterRoot = '../..';
2745+
2746+
final CreateCommand command = CreateCommand();
2747+
final CommandRunner<void> runner = createTestCommandRunner(command);
2748+
2749+
await runner.run(<String>['create', '--no-pub', '--template=plugin_ffi', projectDir.path]);
2750+
expect(logger.errorText, contains(_kNoPlatformsMessage));
2751+
expect(logger.statusText, contains('To add platforms, run `flutter create -t plugin_ffi --platforms <platforms> .` under ${globals.fs.path.normalize(globals.fs.path.relative(projectDir.path))}.'));
2752+
expect(logger.statusText, contains('For more information, see https://flutter.dev/go/plugin-platforms.'));
2753+
2754+
}, overrides: <Type, Generator>{
2755+
FeatureFlags: () => TestFeatureFlags(),
2756+
Logger: ()=> logger,
2757+
});
2758+
27432759
testUsingContext('created plugin with no --platforms flag should not print `no platforms` message if the existing plugin supports a platform.', () async {
27442760
Cache.flutterRoot = '../..';
27452761

0 commit comments

Comments
 (0)