Skip to content

Commit dbf5f04

Browse files
authored
FlutterExtension: make fields non-static (#141463)
There's no issue for this PR. I can create one if requested. ## Summary This PR makes public fields of `FlutterExtension` non-static. The aim is to make migrating from Gradle Groovy DSL to Gradle Kotlin DSL easier for Flutter developers, because... ### Without this PR **android/app/build.gradle.kts** ```kotlin plugins { id "com.android.application" id "dev.flutter.flutter-gradle-plugin" } android { namespace = "io.flutter.examples.hello_world" compileSdk = FlutterExtension.compileSdkVersion defaultConfig { applicationId = "io.flutter.examples.hello_world" minSdk = FlutterExtension.minSdkVersion targetSdk = FlutterExtension.targetSdkVersion // ... } } // ... ``` Groovy and Java allow accessing static fields of a class through its instance, but Kotlin is being more "correct" and disallows that. ### With this PR Thanks to this PR, the user won't have to replace `flutter` with FlutterExtension in some places, thus decreasing possible confusion. ```kotlin plugins { id "com.android.application" id "dev.flutter.flutter-gradle-plugin" } android { namespace = "io.flutter.examples.hello_world" compileSdk = flutter.compileSdkVersion defaultConfig { applicationId = "io.flutter.examples.hello_world" minSdk = flutter.minSdkVersion targetSdk = flutter.targetSdkVersion // ... } } // ... ```
1 parent 4b914bd commit dbf5f04

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/flutter_tools/gradle/src/main/groovy/flutter.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,25 @@ import org.gradle.internal.os.OperatingSystem
4141
*/
4242
class FlutterExtension {
4343
/** Sets the compileSdkVersion used by default in Flutter app projects. */
44-
static int compileSdkVersion = 34
44+
final int compileSdkVersion = 34
4545

4646
/** Sets the minSdkVersion used by default in Flutter app projects. */
47-
static int minSdkVersion = 19
47+
final int minSdkVersion = 19
4848

4949
/**
5050
* Sets the targetSdkVersion used by default in Flutter app projects.
5151
* targetSdkVersion should always be the latest available stable version.
5252
*
5353
* See https://developer.android.com/guide/topics/manifest/uses-sdk-element.
5454
*/
55-
static int targetSdkVersion = 33
55+
final int targetSdkVersion = 33
5656

5757
/**
5858
* Sets the ndkVersion used by default in Flutter app projects.
5959
* Chosen as default version of the AGP version below as found in
6060
* https://developer.android.com/studio/projects/install-ndk#default-ndk-per-agp.
6161
*/
62-
static String ndkVersion = "23.1.7779620"
62+
final String ndkVersion = "23.1.7779620"
6363

6464
/**
6565
* Specifies the relative directory to the Flutter project directory.

0 commit comments

Comments
 (0)