diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index 43fd021eab1..e6def46a8f4 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -236,8 +236,8 @@ class CreateCommand extends CreateBase { withPluginHook: generatePlugin, androidLanguage: stringArg('android-language'), iosLanguage: stringArg('ios-language'), - ios: platforms.contains('ios'), - android: platforms.contains('android'), + ios: featureFlags.isIOSEnabled && platforms.contains('ios'), + android: featureFlags.isAndroidEnabled && platforms.contains('android'), web: featureFlags.isWebEnabled && platforms.contains('web'), linux: featureFlags.isLinuxEnabled && platforms.contains('linux'), macos: featureFlags.isMacOSEnabled && platforms.contains('macos'), diff --git a/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart index 2c71a85b57d..410e2b239b0 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart @@ -100,12 +100,16 @@ void main() { await commandRunner.run([ 'config', + '--enable-android', + '--enable-ios', '--enable-web', '--enable-linux-desktop', '--enable-windows-desktop', '--enable-macos-desktop', ]); + expect(globals.config.getValue('enable-android'), true); + expect(globals.config.getValue('enable-ios'), true); expect(globals.config.getValue('enable-web'), true); expect(globals.config.getValue('enable-linux-desktop'), true); expect(globals.config.getValue('enable-windows-desktop'), true); @@ -115,6 +119,8 @@ void main() { 'config', '--clear-features', ]); + expect(globals.config.getValue('enable-android'), null); + expect(globals.config.getValue('enable-ios'), null); expect(globals.config.getValue('enable-web'), null); expect(globals.config.getValue('enable-linux-desktop'), null); expect(globals.config.getValue('enable-windows-desktop'), null); @@ -122,12 +128,16 @@ void main() { await commandRunner.run([ 'config', + '--no-enable-android', + '--no-enable-ios', '--no-enable-web', '--no-enable-linux-desktop', '--no-enable-windows-desktop', '--no-enable-macos-desktop', ]); + expect(globals.config.getValue('enable-android'), false); + expect(globals.config.getValue('enable-ios'), false); expect(globals.config.getValue('enable-web'), false); expect(globals.config.getValue('enable-linux-desktop'), false); expect(globals.config.getValue('enable-windows-desktop'), false); 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 578711420c3..002701f4427 100755 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -693,6 +693,44 @@ void main() { Logger: () => logger, }); + testUsingContext('app supports android and ios by default', () async { + Cache.flutterRoot = '../..'; + + final CreateCommand command = CreateCommand(); + final CommandRunner runner = createTestCommandRunner(command); + + await runner.run(['create', '--no-pub', projectDir.path]); + + expect(projectDir.childDirectory('android'), exists); + expect(projectDir.childDirectory('ios'), exists); + }, overrides: {}); + + testUsingContext('app does not include android if disabled in config', () async { + Cache.flutterRoot = '../..'; + + final CreateCommand command = CreateCommand(); + final CommandRunner runner = createTestCommandRunner(command); + + await runner.run(['create', '--no-pub', projectDir.path]); + + expect(projectDir.childDirectory('android'), isNot(exists)); + }, overrides: { + FeatureFlags: () => TestFeatureFlags(isAndroidEnabled: false), + }); + + testUsingContext('app does not include ios if disabled in config', () async { + Cache.flutterRoot = '../..'; + + final CreateCommand command = CreateCommand(); + final CommandRunner runner = createTestCommandRunner(command); + + await runner.run(['create', '--no-pub', projectDir.path]); + + expect(projectDir.childDirectory('ios'), isNot(exists)); + }, overrides: { + FeatureFlags: () => TestFeatureFlags(isIOSEnabled: false), + }); + testUsingContext('app does not include desktop or web by default', () async { Cache.flutterRoot = '../..';