From 20d42d7f891f21f24f9a60232dd8259ed9ceb6b0 Mon Sep 17 00:00:00 2001 From: oussama berhili Date: Thu, 16 Jan 2025 15:59:48 +0100 Subject: [PATCH 1/2] Update Android project configuration and dependencies - Upgrade Kotlin version from 1.6.10 to 1.9.20 - Update Android Gradle Plugin from 7.1.2 to 8.1.3 - Change Gradle wrapper version from 7.4 to 8.4 - Modify build.gradle files to use the new plugins DSL - Enhance gradle.properties with additional settings for parallel builds and caching - Update source and target compatibility to Java 17 - Fix Flutter SDK path handling in settings.gradle - Minor formatting adjustments in slidable.dart These changes improve compatibility with the latest tools and enhance build performance. --- example/android/app/build.gradle | 28 ++++++--------- example/android/build.gradle | 8 ++--- example/android/gradle.properties | 5 +++ .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/settings.gradle | 36 ++++++++++++++----- lib/src/slidable.dart | 2 +- 6 files changed, 49 insertions(+), 32 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 97378942..cb364c0c 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') @@ -21,21 +21,24 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'dev.flutter.flutter-gradle-plugin' +} android { + namespace "com.letsar.slidable.example" compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '17' } sourceSets { @@ -43,10 +46,7 @@ android { } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.letsar.slidable.example" - // You can update the following values to match your application needs. - // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. minSdkVersion flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() @@ -55,17 +55,11 @@ android { buildTypes { release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } } } -flutter { - source '../..' -} - dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } diff --git a/example/android/build.gradle b/example/android/build.gradle index 83ae2200..91787214 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.9.20' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' + classpath 'com.android.tools.build:gradle:8.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -21,11 +21,9 @@ allprojects { rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" -} -subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 94adc3a3..c5237d02 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,3 +1,8 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true +org.gradle.parallel=true +org.gradle.caching=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index cc5527d7..fb5eb592 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 44e62bcf..f3f2ed9e 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,11 +1,31 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() + + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } +buildscript { + repositories { + google() + mavenCentral() + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" +} + +include ':app' diff --git a/lib/src/slidable.dart b/lib/src/slidable.dart index a0a38045..ea807979 100644 --- a/lib/src/slidable.dart +++ b/lib/src/slidable.dart @@ -282,7 +282,7 @@ class _SlidableState extends State closeOnScroll: widget.closeOnScroll, child: SlidableDismissal( axis: flipAxis(widget.direction), - controller: controller, + controller: controller, child: ActionPaneConfiguration( alignment: actionPaneAlignment, direction: widget.direction, From 826b312b4ddc95832287afe8c471e350fba19eab Mon Sep 17 00:00:00 2001 From: oussama berhili Date: Thu, 16 Jan 2025 16:21:09 +0100 Subject: [PATCH 2/2] Fix formatting issues in controller.dart and slidable.dart - Corrected the closing markdown comment in the documentation of the openTo method in controller.dart. - Adjusted indentation for the controller parameter in the Slidable widget within slidable.dart. These changes enhance code readability and maintain consistency in documentation formatting. --- lib/src/controller.dart | 2 +- lib/src/slidable.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/controller.dart b/lib/src/controller.dart index fd7ff47f..7894c5df 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -321,7 +321,7 @@ class SlidableController { /// The [ratio] sign will determine which direction the slidable should open. /// ```dart /// controller.openTo(-1); //opens slidable all the way to the left side - /// ``` + /// ``` Future openTo( double ratio, { Duration duration = _defaultMovementDuration, diff --git a/lib/src/slidable.dart b/lib/src/slidable.dart index ea807979..a0a38045 100644 --- a/lib/src/slidable.dart +++ b/lib/src/slidable.dart @@ -282,7 +282,7 @@ class _SlidableState extends State closeOnScroll: widget.closeOnScroll, child: SlidableDismissal( axis: flipAxis(widget.direction), - controller: controller, + controller: controller, child: ActionPaneConfiguration( alignment: actionPaneAlignment, direction: widget.direction,