Unverified Commit e4bde83d authored by Daco Harkes's avatar Daco Harkes Committed by GitHub

plugin_ffi warn about lack of platform support (#106813)

parent 0df48854
......@@ -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<String> 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 <platforms> .` under $pluginPath.
To add platforms, run `flutter create -t $template --platforms <platforms> .` under $pluginPath.
For more information, see https://flutter.dev/go/plugin-platforms.
''');
......
......@@ -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<void> runner = createTestCommandRunner(command);
await runner.run(<String>['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 <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: <Type, Generator>{
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 = '../..';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment