Repository: flutter/flutter
File: packages/flutter_tools/gradle/src/main/kotlin/FlutterPlugin.kt (Kotlin)

Code before:
                //    are not packaged into AAR artifacts - they are only added as dependencies
                //    in pom files.
                // 2. For project dependencies (implementation(project(":flutter"))): The Flutter
                //    Gradle Plugin is not applied to the main app subproject, so this apply()
                //    method is never called.
                //
                // abiFilters cannot be added to templates because it would break builds when
                // --splits-per-abi is used due to conflicting configuration. This approach
                // adds them programmatically only when splits are not configured.
                //
                // If the user has specified abiFilters in their build.gradle file's . DefaultConfig,
                // those settings will take precedence over these defaults.
                configureAbiWithoutSplits(projectToAddTasksTo, androidExtension)
            }
        }

        /**
         * Clears existing abi configuration and sets ABI's supported by flutter.
         */
        private fun configureAbiWithoutSplits(
            projectToAddTasksTo: Project,
            extension: ApplicationExtension
        ) {
            // Developers can set this value by passing `-P disable-abi-filtering=true`
            // to flutter build. Where "disable-abi-filtering" comes from
            // com.flutter.gradle.FlutterPluginUtils.PROP_DISABLE_ABI_FILTERING.
            if (!FlutterPluginUtils.shouldProjectDisableAbiFiltering(projectToAddTasksTo)) {
                extension.defaultConfig.ndk {
                    abiFilters.clear()
                    abiFilters.addAll(PLATFORM_ABI_LIST)
                }
            }
        }

        /**
         * Finds a task by name, returning null if the task does not exist.
         */
        private fun findTaskOrNull(
            project: Project,
            taskName: String
        ): Task? =
            try {
                project.tasks.named(taskName).get()
            } catch (ignored: UnknownTaskException) {
                null
            }

        // TODO(gmackall): Migrate to AGPs variant api.
        //    https://github.com/flutter/flutter/issues/166550
        private fun addFlutterDeps(
            @Suppress("DEPRECATION") variant: com.android.build.gradle.api.BaseVariant,

Review comment (refactor):
nit: I think we should delete this comment. I don't think there is value in explaining the internals of the helper function inline with its use. I think we are overly verbose in comments in this area of the code in general.

Code after:
                //    are not packaged into AAR artifacts - they are only added as dependencies
                //    in pom files.
                // 2. For project dependencies (implementation(project(":flutter"))): The Flutter
                //    Gradle Plugin is not applied to the main app subproject, so this apply()
                //    method is never called.
                //
                // abiFilters cannot be added to templates because it would break builds when
                // --splits-per-abi is used due to conflicting configuration. This approach
                // adds them programmatically only when splits are not configured.
                //
                // If the user has specified abiFilters in their build.gradle file's DefaultConfig,
                // those settings will take precedence over these defaults.
                configureAbiWithoutSplits(projectToAddTasksTo, androidExtension)
            }
        }

        /**
         * Clears existing abi configuration and sets ABI's supported by flutter.
         */
        private fun configureAbiWithoutSplits(
            projectToAddTasksTo: Project,
            extension: ApplicationExtension
        ) {
            if (!FlutterPluginUtils.shouldProjectDisableAbiFiltering(projectToAddTasksTo)) {
                extension.defaultConfig.ndk {
                    abiFilters.clear()
                    abiFilters.addAll(PLATFORM_ABI_LIST)
                }
            }
        }

        /**
         * Finds a task by name, returning null if the task does not exist.
         */
        private fun findTaskOrNull(
            project: Project,
            taskName: String
        ): Task? =
            try {
                project.tasks.named(taskName).get()
            } catch (ignored: UnknownTaskException) {
                null
            }

        // TODO(gmackall): Migrate to AGPs variant api.
        //    https://github.com/flutter/flutter/issues/166550
        private fun addFlutterDeps(
            @Suppress("DEPRECATION") variant: com.android.build.gradle.api.BaseVariant,
            flutterPlugin: FlutterPlugin,
            targetPlatforms: List<String>
        ): Task {