[flutter_tools] Deprecate plugin_ffi template (#181588)

Add deprecation marker to `flutter create --template=plugin_ffi`.

The new way of bundling native code is `flutter create
--template=package_ffi`. (Or if the Flutter Plugin API or Android Play
components need to be bundled: `flutter create --template=plugin)`

Issue:

* https://github.com/flutter/flutter/issues/131209
This commit is contained in:
Daco Harkes 2026-01-29 17:21:04 +01:00 committed by GitHub
parent 3e6c207166
commit bff9bbc1df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 40 additions and 2 deletions

View File

@ -297,6 +297,16 @@ class CreateCommand extends FlutterCommand with CreateBase {
final String? sampleArgument = stringArg('sample');
final bool emptyArgument = boolArg('empty');
final FlutterTemplateType template = _getProjectType(projectDir);
if (template == FlutterTemplateType.pluginFfi) {
globals.printWarning(
'The "plugin_ffi" template is deprecated and will be removed in a future '
'version of Flutter. Use the "package_ffi" template instead. '
'For more information, see: '
'https://docs.flutter.dev/platform-integration/bind-native-code',
);
}
if (sampleArgument != null) {
if (template != FlutterTemplateType.app) {
throwToolExit(

View File

@ -109,9 +109,10 @@ enum FlutterTemplateType implements ParsedFlutterTemplateType {
/// This is an FFI native plugin project.
pluginFfi(
helpText:
'Generate a shareable Flutter project containing an API '
'(deprecated) Generate a shareable Flutter project containing an API '
'in Dart code with a platform-specific implementation through dart:ffi for Android, iOS, '
'Linux, macOS, Windows, or any combination of these.',
'Linux, macOS, Windows, or any combination of these. '
'Use "package_ffi" instead.',
);
const FlutterTemplateType({required this.helpText});

View File

@ -281,6 +281,14 @@ void main() {
),
},
);
testUsingContext('plugin_ffi template is marked as deprecated in help', () {
final command = CreateCommand();
final String? templateHelp =
command.argParser.options['template']?.allowedHelp?['plugin_ffi'];
expect(templateHelp, contains('(deprecated)'));
expect(templateHelp, contains('Use "package_ffi" instead.'));
});
});
}

View File

@ -4279,6 +4279,25 @@ void main() {
);
});
testUsingContext('plugin_ffi template shows deprecation warning', () async {
final command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>[
'create',
'--no-pub',
'--template=plugin_ffi',
'--platforms=android',
projectDir.path,
]);
expect(logger.warningText, contains('The "plugin_ffi" template is deprecated'));
expect(logger.warningText, contains('Use the "package_ffi" template instead.'));
expect(
logger.warningText,
contains('https://docs.flutter.dev/platform-integration/bind-native-code'),
);
}, overrides: {Logger: () => logger});
testUsingContext(
'should show warning when disabled platforms are selected while creating an FFI plugin',
() async {