diff --git a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl index 7baedbe46f..08f05c5738 100644 --- a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl @@ -85,5 +85,6 @@ flutter: # They also do not have any bearing on your native host application's # identifiers, which may be completely independent or the same as these. module: + androidX: {{androidX}} androidPackage: {{androidIdentifier}} iosBundleIdentifier: {{iosIdentifier}} diff --git a/packages/flutter_tools/test/commands/create_test.dart b/packages/flutter_tools/test/commands/create_test.dart index 3b5eee55f6..3707b62a92 100644 --- a/packages/flutter_tools/test/commands/create_test.dart +++ b/packages/flutter_tools/test/commands/create_test.dart @@ -421,6 +421,40 @@ void main() { expect(actualContents.contains('useAndroidX'), false); }, timeout: allowForCreateFlutterProject); + testUsingContext('androidx app module', () async { + Cache.flutterRoot = '../..'; + when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision); + when(mockFlutterVersion.channel).thenReturn(frameworkChannel); + + final CreateCommand command = CreateCommand(); + final CommandRunner runner = createTestCommandRunner(command); + + await runner.run(['create', '--template=module', '--no-pub', '--androidx', projectDir.path]); + + final FlutterProject project = FlutterProject.fromDirectory(projectDir); + expect( + project.usesAndroidX, + true, + ); + }, timeout: allowForCreateFlutterProject); + + testUsingContext('non androidx app module', () async { + Cache.flutterRoot = '../..'; + when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision); + when(mockFlutterVersion.channel).thenReturn(frameworkChannel); + + final CreateCommand command = CreateCommand(); + final CommandRunner runner = createTestCommandRunner(command); + + await runner.run(['create', '--template=module', '--no-pub', '--no-androidx', projectDir.path]); + + final FlutterProject project = FlutterProject.fromDirectory(projectDir); + expect( + project.usesAndroidX, + false, + ); + }, timeout: allowForCreateFlutterProject); + testUsingContext('androidx plugin project', () async { Cache.flutterRoot = '../..'; when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);