Skip to content

Commit 81db537

Browse files
authored
Move from getByName to getByType (flutter#167415)
Fixes flutter#165882 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
1 parent e839c67 commit 81db537

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

packages/flutter_tools/gradle/src/main/kotlin/FlutterPluginUtils.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,8 @@ object FlutterPluginUtils {
403403
return project.extensions.findByType(BaseExtension::class.java)!!
404404
}
405405

406-
// TODO: Use find by type and AbstractAppExtension instead. Or delete in favor of getAndroidExtension.
407-
// see https://github.com/flutter/flutter/issues/165882
408406
private fun getAndroidAppExtensionOrNull(project: Project): AbstractAppExtension? =
409-
project.extensions.findByName("android") as? AbstractAppExtension
407+
project.extensions.findByType(AbstractAppExtension::class.java)
410408

411409
/**
412410
* Expected format of getAndroidExtension(project).compileSdkVersion is a string of the form

packages/flutter_tools/gradle/src/test/kotlin/FlutterPluginUtilsTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ class FlutterPluginUtilsTest {
11081108
every { info(any()) } returns Unit
11091109
every { warn(any()) } returns Unit
11101110
}
1111-
every { extensions.findByName("android") } returns
1111+
every { extensions.findByType(AbstractAppExtension::class.java) } returns
11121112
mockk<AbstractAppExtension> {
11131113
val variant1 =
11141114
mockk<ApplicationVariant> {
@@ -1237,7 +1237,7 @@ class FlutterPluginUtilsTest {
12371237
val mockLogger = mockk<Logger>()
12381238
every { mockProject.logger } returns mockLogger
12391239
every { mockLogger.info(any()) } returns Unit
1240-
every { mockProject.extensions.findByName("android") } returns null
1240+
every { mockProject.extensions.findByType(AbstractAppExtension::class.java) } returns null
12411241

12421242
FlutterPluginUtils.addTasksForOutputsAppLinkSettings(mockProject)
12431243
verify(exactly = 1) { mockLogger.info("addTasksForOutputsAppLinkSettings called on project without android extension.") }

0 commit comments

Comments
 (0)