mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[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:
parent
3e6c207166
commit
bff9bbc1df
@ -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(
|
||||
|
||||
@ -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});
|
||||
|
||||
@ -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.'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user