diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 516e465..c749c04 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -41,6 +41,11 @@ jobs: - name: Check format working-directory: ${{ matrix.package }} run: dart format . --set-exit-if-changed + # Ignoring formatting issues for now, as we're still supporting versions of Flutter below + # 3.29. + # Once the minimum supported version is 3.29 or later, we can enforce this on more recent + # versions. + continue-on-error: true - run: flutter analyze working-directory: ${{ matrix.package }} diff --git a/wakelock_plus/README.md b/wakelock_plus/README.md index d9896bb..4c8bed7 100644 --- a/wakelock_plus/README.md +++ b/wakelock_plus/README.md @@ -33,6 +33,30 @@ automatically. | Windows | ✅ | | Linux | ✅ | +## Framework and Platform Requirements + +* Flutter + - Flutter SDK >=3.22.0 + - Dart SDK >=3.4.0 +* Android + - Android API 21 (Lollipop) or higher + - Java 17 or higher + - Android Gradle Plugin >=8.12.1 + - Gradle wrapper >=8.13 +* iOS + - iOS 12.0 or higher +* macOS + - macOS 10.15 or higher +* Windows + - Windows 7 or higher +* Linux + - gtk+ >= 3.0 + - glib >= 2.0 + - gio >= 2.0 +* Web + - Modern browsers + + ## Usage To use this plugin, follow the [installation guide](https://pub.dev/packages/wakelock_plus/install). @@ -141,7 +165,7 @@ If this occurs, simply add the NDK version specified in the error message in you android { // Current version at the time of this writing. // Use the version specified by the error message. - ndkVersion "25.1.8937393" + ndkVersion flutter.ndkVersion //.... } ``` diff --git a/wakelock_plus/analysis_options.yaml b/wakelock_plus/analysis_options.yaml index 868d700..031ffd7 100644 --- a/wakelock_plus/analysis_options.yaml +++ b/wakelock_plus/analysis_options.yaml @@ -1,5 +1,13 @@ include: package:flutter_lints/flutter.yaml +analyzer: + exclude: + # Generated files shouldn't really be analyzed. Remove if it becomes a problem. + - "**/*.g.dart" + - ".git/**" # Exclude private git directory + - "build/**" # Exclude generated files in the build directory + - ".dart_tool/**" # Exclude Dart tool-generated files + linter: rules: public_member_api_docs: true diff --git a/wakelock_plus/android/build.gradle b/wakelock_plus/android/build.gradle index c5448e6..422cc26 100644 --- a/wakelock_plus/android/build.gradle +++ b/wakelock_plus/android/build.gradle @@ -2,14 +2,14 @@ group 'dev.fluttercommunity.plus.wakelock' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.7.22' + ext.kotlin_version = '2.2.0' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.3.1' + classpath 'com.android.tools.build:gradle:8.12.1' } } @@ -25,7 +25,7 @@ apply plugin: 'kotlin-android' android { namespace 'dev.fluttercommunity.plus.wakelock' - compileSdk 34 + compileSdk = flutter.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_17 @@ -45,7 +45,8 @@ android { } defaultConfig { - minSdkVersion 19 + // Use flutter.minSdkVersion once the minimum supported Flutter version is 3.35 or higher. + minSdkVersion 21 testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } diff --git a/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt b/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt index ca5d62a..8c7aa32 100644 --- a/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt +++ b/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v25.3.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon @file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") @@ -12,25 +12,57 @@ import io.flutter.plugin.common.StandardMethodCodec import io.flutter.plugin.common.StandardMessageCodec import java.io.ByteArrayOutputStream import java.nio.ByteBuffer +private object WakelockPlusMessagesPigeonUtils { -private fun wrapResult(result: Any?): List { - return listOf(result) -} + fun wrapResult(result: Any?): List { + return listOf(result) + } -private fun wrapError(exception: Throwable): List { - return if (exception is WakelockPlusFlutterError) { - listOf( - exception.code, - exception.message, - exception.details - ) - } else { - listOf( - exception.javaClass.simpleName, - exception.toString(), - "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) - ) + fun wrapError(exception: Throwable): List { + return if (exception is WakelockPlusFlutterError) { + listOf( + exception.code, + exception.message, + exception.details + ) + } else { + listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) + } } + fun deepEquals(a: Any?, b: Any?): Boolean { + if (a is ByteArray && b is ByteArray) { + return a.contentEquals(b) + } + if (a is IntArray && b is IntArray) { + return a.contentEquals(b) + } + if (a is LongArray && b is LongArray) { + return a.contentEquals(b) + } + if (a is DoubleArray && b is DoubleArray) { + return a.contentEquals(b) + } + if (a is Array<*> && b is Array<*>) { + return a.size == b.size && + a.indices.all{ deepEquals(a[it], b[it]) } + } + if (a is List<*> && b is List<*>) { + return a.size == b.size && + a.indices.all{ deepEquals(a[it], b[it]) } + } + if (a is Map<*, *> && b is Map<*, *>) { + return a.size == b.size && a.all { + (b as Map).containsKey(it.key) && + deepEquals(it.value, b[it.key]) + } + } + return a == b + } + } /** @@ -44,36 +76,6 @@ class WakelockPlusFlutterError ( override val message: String? = null, val details: Any? = null ) : Throwable() -private fun deepEqualsWakelockPlusMessages(a: Any?, b: Any?): Boolean { - if (a is ByteArray && b is ByteArray) { - return a.contentEquals(b) - } - if (a is IntArray && b is IntArray) { - return a.contentEquals(b) - } - if (a is LongArray && b is LongArray) { - return a.contentEquals(b) - } - if (a is DoubleArray && b is DoubleArray) { - return a.contentEquals(b) - } - if (a is Array<*> && b is Array<*>) { - return a.size == b.size && - a.indices.all{ deepEqualsWakelockPlusMessages(a[it], b[it]) } - } - if (a is List<*> && b is List<*>) { - return a.size == b.size && - a.indices.all{ deepEqualsWakelockPlusMessages(a[it], b[it]) } - } - if (a is Map<*, *> && b is Map<*, *>) { - return a.size == b.size && a.all { - (b as Map).containsKey(it.key) && - deepEqualsWakelockPlusMessages(it.value, b[it.key]) - } - } - return a == b -} - /** * Message for toggling the wakelock on the platform side. @@ -102,7 +104,7 @@ data class ToggleMessage ( if (this === other) { return true } - return deepEqualsWakelockPlusMessages(toList(), other.toList()) } + return WakelockPlusMessagesPigeonUtils.deepEquals(toList(), other.toList()) } override fun hashCode(): Int = toList().hashCode() } @@ -134,7 +136,7 @@ data class IsEnabledMessage ( if (this === other) { return true } - return deepEqualsWakelockPlusMessages(toList(), other.toList()) } + return WakelockPlusMessagesPigeonUtils.deepEquals(toList(), other.toList()) } override fun hashCode(): Int = toList().hashCode() } @@ -193,7 +195,7 @@ interface WakelockPlusApi { api.toggle(msgArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + WakelockPlusMessagesPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -208,7 +210,7 @@ interface WakelockPlusApi { val wrapped: List = try { listOf(api.isEnabled()) } catch (exception: Throwable) { - wrapError(exception) + WakelockPlusMessagesPigeonUtils.wrapError(exception) } reply.reply(wrapped) } diff --git a/wakelock_plus/example/analysis_options.yaml b/wakelock_plus/example/analysis_options.yaml index 61b6c4d..a35c34d 100644 --- a/wakelock_plus/example/analysis_options.yaml +++ b/wakelock_plus/example/analysis_options.yaml @@ -9,6 +9,13 @@ # packages, and plugins designed to encourage good coding practices. include: package:flutter_lints/flutter.yaml +analyzer: + exclude: + - '**.freezed.dart' + - '**.g.dart' + - '**.gr.dart' + - '**/generated_plugin_registrant.dart' + linter: # The lint rules applied to this project can be customized in the # section below to disable rules from the `package:flutter_lints/flutter.yaml` diff --git a/wakelock_plus/example/android/app/build.gradle b/wakelock_plus/example/android/app/build.gradle index 678448f..c53cd6c 100644 --- a/wakelock_plus/example/android/app/build.gradle +++ b/wakelock_plus/example/android/app/build.gradle @@ -22,8 +22,8 @@ if (flutterVersionName == null) { } android { - compileSdk 34 - ndkVersion "25.1.8937393" + compileSdk flutter.compileSdkVersion + ndkVersion flutter.ndkVersion namespace 'dev.fluttercommunity.plus.wakelock_example' compileOptions { @@ -44,8 +44,8 @@ android { applicationId 'dev.fluttercommunity.plus.wakelock_example' // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. - minSdk 19 - targetSdk 34 + minSdk flutter.minSdkVersion + targetSdk flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/wakelock_plus/example/android/gradle/wrapper/gradle-wrapper.properties b/wakelock_plus/example/android/gradle/wrapper/gradle-wrapper.properties index 11fce01..20014ed 100644 --- a/wakelock_plus/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/wakelock_plus/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip diff --git a/wakelock_plus/example/android/settings.gradle b/wakelock_plus/example/android/settings.gradle index d78c69d..6b12c9f 100644 --- a/wakelock_plus/example/android/settings.gradle +++ b/wakelock_plus/example/android/settings.gradle @@ -18,7 +18,7 @@ pluginManagement { plugins { id 'dev.flutter.flutter-plugin-loader' version '1.0.0' - id 'com.android.application' version '8.3.1' apply false - id 'org.jetbrains.kotlin.android' version '1.8.22' apply false + id "com.android.application" version "8.13.0" apply false + id "org.jetbrains.kotlin.android" version "2.2.20" apply false } include ':app' diff --git a/wakelock_plus/ios/wakelock_plus/Sources/wakelock_plus/include/wakelock_plus/messages.g.h b/wakelock_plus/ios/wakelock_plus/Sources/wakelock_plus/include/wakelock_plus/messages.g.h index c4220b2..e9ccc22 100644 --- a/wakelock_plus/ios/wakelock_plus/Sources/wakelock_plus/include/wakelock_plus/messages.g.h +++ b/wakelock_plus/ios/wakelock_plus/Sources/wakelock_plus/include/wakelock_plus/messages.g.h @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v25.3.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon #import diff --git a/wakelock_plus/ios/wakelock_plus/Sources/wakelock_plus/messages.g.m b/wakelock_plus/ios/wakelock_plus/Sources/wakelock_plus/messages.g.m index e799845..1a2154c 100644 --- a/wakelock_plus/ios/wakelock_plus/Sources/wakelock_plus/messages.g.m +++ b/wakelock_plus/ios/wakelock_plus/Sources/wakelock_plus/messages.g.m @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v25.3.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "./include/wakelock_plus/messages.g.h" diff --git a/wakelock_plus/pubspec.yaml b/wakelock_plus/pubspec.yaml index b0140f4..3e5ad53 100644 --- a/wakelock_plus/pubspec.yaml +++ b/wakelock_plus/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: # Linux dependencies dbus: ^0.7.11 - package_info_plus: ">=6.0.0 <9.0.0" + package_info_plus: ">=9.0.0" # Web dependencies web: ">=0.5.1 <2.0.0" @@ -31,8 +31,8 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^5.0.0 - pigeon: ^25.3.0 # dart run pigeon --input "pigeons/messages.dart" + flutter_lints: ^6.0.0 + pigeon: ^26.0.1 # dart run pigeon --input "pigeons/messages.dart" # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/wakelock_plus_platform_interface/analysis_options.yaml b/wakelock_plus_platform_interface/analysis_options.yaml index 03675ff..a02c402 100644 --- a/wakelock_plus_platform_interface/analysis_options.yaml +++ b/wakelock_plus_platform_interface/analysis_options.yaml @@ -2,8 +2,11 @@ include: package:flutter_lints/flutter.yaml analyzer: exclude: - - lib/**.g.dart - - test/**.g.dart + # Generated files shouldn't really be analyzed. Remove if it becomes a problem. + - "**/*.g.dart" + - ".git/**" # Exclude private git directory + - "build/**" # Exclude generated files in the build directory + - ".dart_tool/**" # Exclude Dart tool-generated files linter: rules: diff --git a/wakelock_plus_platform_interface/lib/messages.g.dart b/wakelock_plus_platform_interface/lib/messages.g.dart index 5e00c0a..0546d2e 100644 --- a/wakelock_plus_platform_interface/lib/messages.g.dart +++ b/wakelock_plus_platform_interface/lib/messages.g.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v25.3.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers diff --git a/wakelock_plus_platform_interface/pubspec.yaml b/wakelock_plus_platform_interface/pubspec.yaml index 01995dd..035b3a1 100644 --- a/wakelock_plus_platform_interface/pubspec.yaml +++ b/wakelock_plus_platform_interface/pubspec.yaml @@ -7,8 +7,8 @@ repository: >-2 https://github.com/fluttercommunity/wakelock_plus/tree/main/wakelock_plus_platform_interface environment: - sdk: '>=3.3.0 <4.0.0' - flutter: ">=3.19.0" + sdk: '>=3.4.0 <4.0.0' + flutter: ">=3.22.0" dependencies: flutter: @@ -20,4 +20,4 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^5.0.0 + flutter_lints: ^6.0.0 diff --git a/wakelock_plus_platform_interface/test/messages.g.dart b/wakelock_plus_platform_interface/test/messages.g.dart index e863826..53a05ae 100644 --- a/wakelock_plus_platform_interface/test/messages.g.dart +++ b/wakelock_plus_platform_interface/test/messages.g.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v25.3.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import, no_leading_underscores_for_local_identifiers // ignore_for_file: avoid_relative_lib_imports