diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml
index d03b8e21..9f77fa51 100644
--- a/.github/workflows/format.yml
+++ b/.github/workflows/format.yml
@@ -16,17 +16,19 @@ jobs:
channel: 'stable'
- name: Format
run: |
- flutter format --set-exit-if-changed .
+ dart format --set-exit-if-changed .
format_kotlin:
runs-on: ubuntu-latest
steps:
- name: "checkout"
- - uses: actions/checkout@v4
+ uses: actions/checkout@v4
- - name: "ktlint"
- uses: "vroy/gha-kotlin-linter@v1"
+ - name: ktlint
+ uses: ScaCap/action-ktlint@master
+ with:
+ github_token: ${{ secrets.github_token }}
format_swift:
runs-on: ubuntu-latest
@@ -45,6 +47,7 @@ jobs:
- name: publish checks
run: |
+ cd workmanager
flutter pub get
flutter pub publish -n
flutter pub global activate tuneup
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index d3943c45..9063cdd6 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -16,6 +16,7 @@ jobs:
channel: 'stable'
- name: Test
run: |
+ cd workmanager
flutter pub get
flutter test
diff --git a/.gitignore b/.gitignore
index a412d0cc..6e9640b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,6 @@ doc/api/*/
.fvm
*.iml
.dccache
+
+
+pubspec_overrides.yaml
diff --git a/android/src/test/java/ExtractorTests.kt b/android/src/test/java/ExtractorTests.kt
deleted file mode 100644
index 77dddeb9..00000000
--- a/android/src/test/java/ExtractorTests.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-import androidx.work.NetworkType
-import androidx.work.OutOfQuotaPolicy
-import dev.fluttercommunity.workmanager.Extractor
-import io.flutter.plugin.common.MethodCall
-import org.junit.Assert.assertEquals
-import org.junit.Test
-
-class ExtractorTests {
- @Test
- fun shouldParseOutOfQuotaPolicyFromCall() {
- val all = mapOf(
- null to null,
- "drop_work_request" to OutOfQuotaPolicy.DROP_WORK_REQUEST,
- "run_as_non_expedited_work_request" to
- OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST
- )
-
- all.forEach { (dartString, wmConstant) ->
- val call = MethodCall(
- "",
- mapOf("outOfQuotaPolicy" to dartString)
- )
- assertEquals(Extractor.extractOutOfQuotaPolicyFromCall(call), wmConstant)
- }
- }
-
- @Test
- fun shouldParseNetworkTypeFromCall() {
- val all = mapOf(
- "unmetered" to NetworkType.UNMETERED,
- "metered" to NetworkType.METERED,
- "not_required" to NetworkType.NOT_REQUIRED,
- "not_roaming" to NetworkType.NOT_ROAMING,
- "temporarily_unmetered" to NetworkType.TEMPORARILY_UNMETERED,
- "connected" to NetworkType.CONNECTED
- )
-
- all.forEach { (dartString, wmConstant) ->
- val call = MethodCall(
- "",
- mapOf(
- "networkType" to dartString
- )
- )
- val constraints = Extractor.extractConstraintConfigFromCall(call)
-
- assertEquals(constraints.requiredNetworkType, wmConstant)
- }
- }
-}
diff --git a/example/.gitignore b/example/.gitignore
index ac4a9064..29a3a501 100644
--- a/example/.gitignore
+++ b/example/.gitignore
@@ -8,6 +8,7 @@
.buildlog/
.history
.svn/
+migrate_working_dir/
# IntelliJ related
*.iml
@@ -22,51 +23,21 @@
# Flutter/Dart/Pub related
**/doc/api/
+**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
-.packages
+.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/
-# Android related
-**/android/**/gradle-wrapper.jar
-**/android/.gradle
-**/android/captures/
-**/android/gradlew
-**/android/gradlew.bat
-**/android/local.properties
-**/android/**/GeneratedPluginRegistrant.java
+# Symbolication related
+app.*.symbols
-# iOS/XCode related
-**/ios/**/*.mode1v3
-**/ios/**/*.mode2v3
-**/ios/**/*.moved-aside
-**/ios/**/*.pbxuser
-**/ios/**/*.perspectivev3
-**/ios/**/*sync/
-**/ios/**/.sconsign.dblite
-**/ios/**/.tags*
-**/ios/**/.vagrant/
-**/ios/**/DerivedData/
-**/ios/**/Icon?
-**/ios/**/Pods/
-**/ios/**/.symlinks/
-**/ios/**/profile
-**/ios/**/xcuserdata
-**/ios/.generated/
-**/ios/Flutter/App.framework
-**/ios/Flutter/Flutter.framework
-**/ios/Flutter/Generated.xcconfig
-**/ios/Flutter/app.flx
-**/ios/Flutter/app.zip
-**/ios/Flutter/flutter_assets/
-**/ios/ServiceDefinitions.json
-**/ios/Runner/GeneratedPluginRegistrant.*
+# Obfuscation related
+app.*.map.json
-# Exceptions to above rules.
-!**/ios/**/default.mode1v3
-!**/ios/**/default.mode2v3
-!**/ios/**/default.pbxuser
-!**/ios/**/default.perspectivev3
-!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
+# Android Studio will place build artifacts here
+/android/app/debug
+/android/app/profile
+/android/app/release
diff --git a/example/android/.gitignore b/example/android/.gitignore
new file mode 100644
index 00000000..6f568019
--- /dev/null
+++ b/example/android/.gitignore
@@ -0,0 +1,13 @@
+gradle-wrapper.jar
+/.gradle
+/captures/
+/gradlew
+/gradlew.bat
+/local.properties
+GeneratedPluginRegistrant.java
+
+# Remember to never publicly share your keystore.
+# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
+key.properties
+**/*.keystore
+**/*.jks
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index e878147f..769e3794 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -37,9 +37,9 @@ android {
defaultConfig {
applicationId "dev.fluttercommunity.workmanager.example"
- compileSdk 33
+ compileSdk 34
minSdkVersion 19
- targetSdkVersion 33
+ targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
diff --git a/example/ios/.gitignore b/example/ios/.gitignore
new file mode 100644
index 00000000..7a7f9873
--- /dev/null
+++ b/example/ios/.gitignore
@@ -0,0 +1,34 @@
+**/dgph
+*.mode1v3
+*.mode2v3
+*.moved-aside
+*.pbxuser
+*.perspectivev3
+**/*sync/
+.sconsign.dblite
+.tags*
+**/.vagrant/
+**/DerivedData/
+Icon?
+**/Pods/
+**/.symlinks/
+profile
+xcuserdata
+**/.generated/
+Flutter/App.framework
+Flutter/Flutter.framework
+Flutter/Flutter.podspec
+Flutter/Generated.xcconfig
+Flutter/ephemeral/
+Flutter/app.flx
+Flutter/app.zip
+Flutter/flutter_assets/
+Flutter/flutter_export_environment.sh
+ServiceDefinitions.json
+Runner/GeneratedPluginRegistrant.*
+
+# Exceptions to above rules.
+!default.mode1v3
+!default.mode2v3
+!default.pbxuser
+!default.perspectivev3
diff --git a/example/ios/Flutter/.last_build_id b/example/ios/Flutter/.last_build_id
deleted file mode 100644
index 6d7ce45c..00000000
--- a/example/ios/Flutter/.last_build_id
+++ /dev/null
@@ -1 +0,0 @@
-e4704dc1c34044d70c8863f668207456
\ No newline at end of file
diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist
index 4f8d4d24..8c6e5614 100644
--- a/example/ios/Flutter/AppFrameworkInfo.plist
+++ b/example/ios/Flutter/AppFrameworkInfo.plist
@@ -21,6 +21,6 @@
CFBundleVersion
1.0
MinimumOSVersion
- 11.0
+ 12.0
diff --git a/example/ios/Flutter/Flutter.podspec b/example/ios/Flutter/Flutter.podspec
deleted file mode 100644
index 8ce43943..00000000
--- a/example/ios/Flutter/Flutter.podspec
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# NOTE: This podspec is NOT to be published. It is only used as a local source!
-# This is a generated file; do not edit or check into version control.
-#
-
-Pod::Spec.new do |s|
- s.name = 'Flutter'
- s.version = '1.0.0'
- s.summary = 'A UI toolkit for beautiful and fast apps.'
- s.homepage = 'https://flutter.dev'
- s.license = { :type => 'BSD' }
- s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
- s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
- s.ios.deployment_target = '11.0'
- # Framework linking is handled by Flutter tooling, not CocoaPods.
- # Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
- s.vendored_frameworks = 'path/to/nothing'
-end
diff --git a/example/ios/Podfile b/example/ios/Podfile
index ca35e86a..d58567a0 100644
--- a/example/ios/Podfile
+++ b/example/ios/Podfile
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
-platform :ios, '11.0'
+platform :ios, '12.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index d973a3cd..8401fc3e 100644
--- a/example/ios/Podfile.lock
+++ b/example/ios/Podfile.lock
@@ -14,8 +14,8 @@ PODS:
DEPENDENCIES:
- Flutter (from `Flutter`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
- - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
+ - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
+ - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- workmanager (from `.symlinks/plugins/workmanager/ios`)
EXTERNAL SOURCES:
@@ -24,19 +24,19 @@ EXTERNAL SOURCES:
integration_test:
:path: ".symlinks/plugins/integration_test/ios"
path_provider_foundation:
- :path: ".symlinks/plugins/path_provider_foundation/ios"
+ :path: ".symlinks/plugins/path_provider_foundation/darwin"
shared_preferences_foundation:
- :path: ".symlinks/plugins/shared_preferences_foundation/ios"
+ :path: ".symlinks/plugins/shared_preferences_foundation/darwin"
workmanager:
:path: ".symlinks/plugins/workmanager/ios"
SPEC CHECKSUMS:
- Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
- integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5
- path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9
- shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472
+ Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
+ integration_test: 13825b8a9334a850581300559b8839134b124670
+ path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
+ shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
workmanager: 0afdcf5628bbde6924c21af7836fed07b42e30e6
-PODFILE CHECKSUM: 1f97605dfe28dbf01a36d8763312d21d5d00222c
+PODFILE CHECKSUM: b63d507eb7cc768afa26646638aaf07f371f6370
-COCOAPODS: 1.12.0
+COCOAPODS: 1.14.3
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index d0b9ce96..398caff3 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -226,7 +226,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1250;
- LastUpgradeCheck = 1300;
+ LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
@@ -307,6 +307,7 @@
files = (
);
inputPaths = (
+ "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
index 7261287f..6b988772 100644
--- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
+++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -1,6 +1,6 @@
{
child: Text("isscheduled (Android)"),
onPressed: Platform.isAndroid
? () async {
- final workInfo = await Workmanager().isScheduledByUniqueName(
+ final workInfo =
+ await Workmanager().isScheduledByUniqueName(
simplePeriodicTask,
);
print('isscheduled = $workInfo');
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index 699a8bfa..1b5ee845 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -10,6 +10,7 @@ dependencies:
shared_preferences: ^2.2.1
flutter:
sdk: flutter
+ workmanager:
dev_dependencies:
integration_test:
@@ -17,8 +18,5 @@ dev_dependencies:
flutter_test:
sdk: flutter
- workmanager:
- path: ../
-
flutter:
uses-material-design: true
\ No newline at end of file
diff --git a/melos.yaml b/melos.yaml
new file mode 100644
index 00000000..902e5a03
--- /dev/null
+++ b/melos.yaml
@@ -0,0 +1,10 @@
+name: workmanager
+packages:
+ - workmanager
+ - example
+scripts:
+ get: melos exec -- dart pub get
+
+ generate:dart:
+ run: melos exec -c 1 --depends-on="build_runner" --no-flutter -- "dart run build_runner build --delete-conflicting-outputs"
+ description: Build all generated files for Dart packages in this project.
diff --git a/pubspec.yaml b/pubspec.yaml
index 8fbc2298..1cff8be6 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,32 +1,6 @@
-name: workmanager
-description: Flutter Workmanager. This plugin allows you to schedule background work on Android and iOS.
-version: 0.5.2
-homepage: https://github.com/fluttercommunity/flutter_workmanager
-repository: https://github.com/fluttercommunity/flutter_workmanager
-issue_tracker: https://github.com/fluttercommunity/flutter_workmanager/issues
+name: workmanager_workspace
environment:
- sdk: '>=3.1.2 <4.0.0'
- flutter: ">=2.5.0"
-
-dependencies:
- flutter:
- sdk: flutter
-
+ sdk: '>=2.17.0 <3.0.0'
dev_dependencies:
- build_runner: ^2.1.7
- test: ^1.16.3
- mockito: ^5.0.4
- get_it: ^7.2.0
- flutter_test:
- sdk: flutter
- flutter_lints: ^2.0.1
-
-flutter:
- plugin:
- platforms:
- android:
- package: dev.fluttercommunity.workmanager
- pluginClass: WorkmanagerPlugin
- ios:
- pluginClass: WorkmanagerPlugin
+ melos: ^3.1.0
diff --git a/.metadata b/workmanager/.metadata
similarity index 100%
rename from .metadata
rename to workmanager/.metadata
diff --git a/CHANGELOG.md b/workmanager/CHANGELOG.md
similarity index 100%
rename from CHANGELOG.md
rename to workmanager/CHANGELOG.md
diff --git a/LICENSE b/workmanager/LICENSE
similarity index 100%
rename from LICENSE
rename to workmanager/LICENSE
diff --git a/analysis_options.yml b/workmanager/analysis_options.yml
similarity index 100%
rename from analysis_options.yml
rename to workmanager/analysis_options.yml
diff --git a/android/.gitignore b/workmanager/android/.gitignore
similarity index 100%
rename from android/.gitignore
rename to workmanager/android/.gitignore
diff --git a/android/build.gradle b/workmanager/android/build.gradle
similarity index 100%
rename from android/build.gradle
rename to workmanager/android/build.gradle
diff --git a/android/gradle.properties b/workmanager/android/gradle.properties
similarity index 100%
rename from android/gradle.properties
rename to workmanager/android/gradle.properties
diff --git a/android/settings.gradle b/workmanager/android/settings.gradle
similarity index 100%
rename from android/settings.gradle
rename to workmanager/android/settings.gradle
diff --git a/android/src/main/AndroidManifest.xml b/workmanager/android/src/main/AndroidManifest.xml
similarity index 100%
rename from android/src/main/AndroidManifest.xml
rename to workmanager/android/src/main/AndroidManifest.xml
diff --git a/android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt
similarity index 90%
rename from android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt
rename to workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt
index c433a3ff..08367891 100644
--- a/android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt
+++ b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt
@@ -11,7 +11,6 @@ import com.google.common.util.concurrent.ListenableFuture
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.embedding.engine.dart.DartExecutor
import io.flutter.embedding.engine.loader.FlutterLoader
-import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.view.FlutterCallbackInformation
@@ -24,9 +23,8 @@ import java.util.Random
*/
class BackgroundWorker(
applicationContext: Context,
- private val workerParams: WorkerParameters
+ private val workerParams: WorkerParameters,
) : ListenableWorker(applicationContext, workerParams), MethodChannel.MethodCallHandler {
-
private lateinit var backgroundChannel: MethodChannel
companion object {
@@ -59,10 +57,11 @@ class BackgroundWorker(
private var completer: CallbackToFutureAdapter.Completer? = null
- private var resolvableFuture = CallbackToFutureAdapter.getFuture { completer ->
- this.completer = completer
- null
- }
+ private var resolvableFuture =
+ CallbackToFutureAdapter.getFuture { completer ->
+ this.completer = completer
+ null
+ }
override fun startWork(): ListenableFuture {
startTime = System.currentTimeMillis()
@@ -76,7 +75,7 @@ class BackgroundWorker(
flutterLoader.ensureInitializationCompleteAsync(
applicationContext,
null,
- Handler(Looper.getMainLooper())
+ Handler(Looper.getMainLooper()),
) {
val callbackHandle = SharedPreferenceHelper.getCallbackHandle(applicationContext)
val callbackInfo = FlutterCallbackInformation.lookupCallbackInformation(callbackHandle)
@@ -90,7 +89,7 @@ class BackgroundWorker(
payload,
callbackHandle,
callbackInfo,
- dartBundlePath
+ dartBundlePath,
)
}
@@ -102,8 +101,8 @@ class BackgroundWorker(
DartExecutor.DartCallback(
applicationContext.assets,
dartBundlePath,
- callbackInfo
- )
+ callbackInfo,
+ ),
)
}
}
@@ -125,7 +124,7 @@ class BackgroundWorker(
dartTask,
payload,
fetchDuration,
- result ?: Result.failure()
+ result ?: Result.failure(),
)
}
@@ -142,7 +141,10 @@ class BackgroundWorker(
}
}
- override fun onMethodCall(call: MethodCall, r: MethodChannel.Result) {
+ override fun onMethodCall(
+ call: MethodCall,
+ r: MethodChannel.Result,
+ ) {
when (call.method) {
BACKGROUND_CHANNEL_INITIALIZED ->
backgroundChannel.invokeMethod(
@@ -156,7 +158,7 @@ class BackgroundWorker(
override fun error(
errorCode: String,
errorMessage: String?,
- errorDetails: Any?
+ errorDetails: Any?,
) {
Log.e(TAG, "errorCode: $errorCode, errorMessage: $errorMessage")
stopEngine(Result.failure())
@@ -166,7 +168,7 @@ class BackgroundWorker(
val wasSuccessFul = receivedResult?.let { it as Boolean? } == true
stopEngine(if (wasSuccessFul) Result.success() else Result.retry())
}
- }
+ },
)
}
}
diff --git a/android/src/main/kotlin/dev/fluttercommunity/workmanager/DebugHelper.kt b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/DebugHelper.kt
similarity index 60%
rename from android/src/main/kotlin/dev/fluttercommunity/workmanager/DebugHelper.kt
rename to workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/DebugHelper.kt
index 08a200b1..8b70c5aa 100644
--- a/android/src/main/kotlin/dev/fluttercommunity/workmanager/DebugHelper.kt
+++ b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/DebugHelper.kt
@@ -22,15 +22,14 @@ object ThumbnailGenerator {
}
object DebugHelper {
- private const val debugChannelId = "WorkmanagerDebugChannelId"
- private const val debugChannelName = "A helper channel to debug your background tasks."
+ private const val DEBUG_CHANNEL_ID = "WorkmanagerDebugChannelId"
+ private const val DEBUG_CHANNEL_NAME = "A helper channel to debug your background tasks."
private val debugDateFormatter =
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM)
private val currentTime get() = debugDateFormatter.format(Date())
- private fun mapMillisToSeconds(milliseconds: Long) =
- "${MILLISECONDS.toSeconds(milliseconds)} seconds."
+ private fun mapMillisToSeconds(milliseconds: Long) = "${MILLISECONDS.toSeconds(milliseconds)} seconds."
fun postTaskCompleteNotification(
ctx: Context,
@@ -38,18 +37,18 @@ object DebugHelper {
dartTask: String,
payload: String? = null,
fetchDuration: Long,
- result: ListenableWorker.Result
+ result: ListenableWorker.Result,
) {
postNotification(
ctx,
threadIdentifier,
"${ThumbnailGenerator.workEmoji} $currentTime",
"""
- • Result: ${ThumbnailGenerator.mapResultToEmoji(result)} ${result.javaClass.simpleName}
- • dartTask: $dartTask
- • inputData: ${payload ?: "not found"}
- • Elapsed time: ${mapMillisToSeconds(fetchDuration)}
- """.trimIndent()
+ • Result: ${ThumbnailGenerator.mapResultToEmoji(result)} ${result.javaClass.simpleName}
+ • dartTask: $dartTask
+ • inputData: ${payload ?: "not found"}
+ • Elapsed time: ${mapMillisToSeconds(fetchDuration)}
+ """.trimIndent(),
)
}
@@ -60,40 +59,44 @@ object DebugHelper {
payload: String? = null,
callbackHandle: Long,
callbackInfo: FlutterCallbackInformation?,
- dartBundlePath: String?
+ dartBundlePath: String?,
) {
postNotification(
ctx,
threadIdentifier,
"${ThumbnailGenerator.workEmoji} $currentTime",
"""
- • dartTask: $dartTask
- • inputData: ${payload ?: "not found"}
- • callbackHandle: $callbackHandle
- • callBackName: ${callbackInfo?.callbackName ?: "not found"}
- • callbackClassName: ${callbackInfo?.callbackClassName ?: "not found"}
- • callbackLibraryPath: ${callbackInfo?.callbackLibraryPath ?: "not found"}
- • dartBundlePath: $dartBundlePath"
- """.trimIndent()
-
+ • dartTask: $dartTask
+ • inputData: ${payload ?: "not found"}
+ • callbackHandle: $callbackHandle
+ • callBackName: ${callbackInfo?.callbackName ?: "not found"}
+ • callbackClassName: ${callbackInfo?.callbackClassName ?: "not found"}
+ • callbackLibraryPath: ${callbackInfo?.callbackLibraryPath ?: "not found"}
+ • dartBundlePath: $dartBundlePath"
+ """.trimIndent(),
)
}
- private fun postNotification(ctx: Context, messageId: Int, title: String, contentText: String) {
+ private fun postNotification(
+ ctx: Context,
+ messageId: Int,
+ title: String,
+ contentText: String,
+ ) {
(ctx.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).apply {
createNotificationChannel()
notify(
messageId,
- NotificationCompat.Builder(ctx, debugChannelId)
+ NotificationCompat.Builder(ctx, DEBUG_CHANNEL_ID)
.setContentTitle(title)
.setContentText(contentText)
.setStyle(
NotificationCompat.BigTextStyle()
- .bigText(contentText)
+ .bigText(contentText),
)
.setSmallIcon(android.R.drawable.stat_notify_sync)
- .build()
+ .build(),
)
}
}
@@ -102,10 +105,10 @@ object DebugHelper {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createNotificationChannel(
NotificationChannel(
- debugChannelId,
- debugChannelName,
- NotificationManager.IMPORTANCE_DEFAULT
- )
+ DEBUG_CHANNEL_ID,
+ DEBUG_CHANNEL_NAME,
+ NotificationManager.IMPORTANCE_DEFAULT,
+ ),
)
}
}
diff --git a/android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt
similarity index 85%
rename from android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt
rename to workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt
index dceec313..4ac69596 100644
--- a/android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt
+++ b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/Extractor.kt
@@ -7,15 +7,14 @@ import androidx.work.Constraints
import androidx.work.ExistingPeriodicWorkPolicy
import androidx.work.ExistingWorkPolicy
import androidx.work.NetworkType
-import androidx.work.OneTimeWorkRequest
import androidx.work.OutOfQuotaPolicy
import androidx.work.PeriodicWorkRequest
import androidx.work.WorkRequest
import dev.fluttercommunity.workmanager.WorkManagerCall.CancelTask.ByTag.KEYS.UNREGISTER_TASK_TAG_KEY
import dev.fluttercommunity.workmanager.WorkManagerCall.CancelTask.ByUniqueName.KEYS.UNREGISTER_TASK_UNIQUE_NAME_KEY
-import dev.fluttercommunity.workmanager.WorkManagerCall.IsScheduled.ByUniqueName.KEYS.IS_SCHEDULED_UNIQUE_NAME_KEY
import dev.fluttercommunity.workmanager.WorkManagerCall.Initialize.KEYS.INITIALIZE_TASK_CALL_HANDLE_KEY
import dev.fluttercommunity.workmanager.WorkManagerCall.Initialize.KEYS.INITIALIZE_TASK_IS_IN_DEBUG_MODE_KEY
+import dev.fluttercommunity.workmanager.WorkManagerCall.IsScheduled.ByUniqueName.KEYS.IS_SCHEDULED_UNIQUE_NAME_KEY
import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_BACK_OFF_POLICY_DELAY_MILLIS_KEY
import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_BACK_OFF_POLICY_TYPE_KEY
import dev.fluttercommunity.workmanager.WorkManagerCall.RegisterTask.KEYS.REGISTER_TASK_CONSTRAINTS_BATTERY_NOT_LOW_KEY
@@ -42,25 +41,25 @@ val defaultOutOfQuotaPolicy: OutOfQuotaPolicy? = null
val defaultOneOffExistingWorkPolicy = ExistingWorkPolicy.KEEP
val defaultPeriodExistingWorkPolicy = ExistingPeriodicWorkPolicy.KEEP
val defaultConstraints: Constraints = Constraints.NONE
-const val defaultInitialDelaySeconds = 0L
-const val defaultRequestedBackoffDelay = 0L
-const val defaultPeriodicRefreshFrequencyInSeconds =
+const val DEFAULT_INITIAL_DELAY_SECONDS = 0L
+const val DEFAULT_REQUESTED_BACKOFF_DELAY = 0L
+const val DEFAULT_PERIODIC_REFRESH_FREQUENCY_SECONDS =
PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS / 1000
-const val defaultFlexIntervalInSeconds =
+const val DEFAULT_FLEX_INTERVAL_SECONDS =
PeriodicWorkRequest.MIN_PERIODIC_FLEX_MILLIS / 1000
-const val logTag = "Extractor"
+const val LOG_TAG = "Extractor"
data class BackoffPolicyTaskConfig(
val backoffPolicy: BackoffPolicy,
private val requestedBackoffDelay: Long,
private val minBackoffInMillis: Long,
- val backoffDelay: Long = max(minBackoffInMillis, requestedBackoffDelay)
+ val backoffDelay: Long = max(minBackoffInMillis, requestedBackoffDelay),
)
sealed class WorkManagerCall {
data class Initialize(
val callbackDispatcherHandleKey: Long,
- val isInDebugMode: Boolean
+ val isInDebugMode: Boolean,
) : WorkManagerCall() {
companion object KEYS {
const val INITIALIZE_TASK_IS_IN_DEBUG_MODE_KEY = "isInDebugMode"
@@ -108,7 +107,7 @@ sealed class WorkManagerCall {
override val constraintsConfig: Constraints,
val backoffPolicyConfig: BackoffPolicyTaskConfig?,
val outOfQuotaPolicy: OutOfQuotaPolicy?,
- override val payload: String? = null
+ override val payload: String? = null,
) : RegisterTask()
data class PeriodicTask(
@@ -123,7 +122,7 @@ sealed class WorkManagerCall {
override val constraintsConfig: Constraints,
val backoffPolicyConfig: BackoffPolicyTaskConfig?,
val outOfQuotaPolicy: OutOfQuotaPolicy?,
- override val payload: String? = null
+ override val payload: String? = null,
) : RegisterTask() {
companion object KEYS {
const val PERIODIC_TASK_FREQUENCY_SECONDS_KEY = "frequency"
@@ -163,7 +162,7 @@ sealed class WorkManagerCall {
private enum class TaskType(val minimumBackOffDelay: Long) {
ONE_OFF(WorkRequest.MIN_BACKOFF_MILLIS),
- PERIODIC(WorkRequest.MIN_BACKOFF_MILLIS)
+ PERIODIC(WorkRequest.MIN_BACKOFF_MILLIS),
}
object Extractor {
@@ -179,7 +178,8 @@ object Extractor {
CANCEL_TASK_BY_TAG("cancelTaskByTag"),
CANCEL_ALL("cancelAllTasks"),
- UNKNOWN(null);
+ UNKNOWN(null),
+ ;
companion object {
fun fromRawMethodName(methodName: String): PossibleWorkManagerCall =
@@ -212,11 +212,12 @@ object Extractor {
initialDelaySeconds = extractInitialDelayFromCall(call),
constraintsConfig = extractConstraintConfigFromCall(call),
outOfQuotaPolicy = extractOutOfQuotaPolicyFromCall(call),
- backoffPolicyConfig = extractBackoffPolicyConfigFromCall(
- call,
- TaskType.ONE_OFF
- ),
- payload = extractPayload(call)
+ backoffPolicyConfig =
+ extractBackoffPolicyConfigFromCall(
+ call,
+ TaskType.ONE_OFF,
+ ),
+ payload = extractPayload(call),
)
}
PossibleWorkManagerCall.REGISTER_PERIODIC_TASK -> {
@@ -226,33 +227,36 @@ object Extractor {
taskName = call.argument(REGISTER_TASK_NAME_VALUE_KEY)!!,
frequencyInSeconds = extractFrequencySecondsFromCall(call),
tag = call.argument(REGISTER_TASK_TAG_KEY),
- flexIntervalInSeconds =extractFlexIntervalSecondsFromCall(call) ,
+ flexIntervalInSeconds = extractFlexIntervalSecondsFromCall(call),
existingWorkPolicy = extractExistingPeriodicWorkPolicyFromCall(call),
initialDelaySeconds = extractInitialDelayFromCall(call),
constraintsConfig = extractConstraintConfigFromCall(call),
- backoffPolicyConfig = extractBackoffPolicyConfigFromCall(
- call,
- TaskType.PERIODIC
- ),
+ backoffPolicyConfig =
+ extractBackoffPolicyConfigFromCall(
+ call,
+ TaskType.PERIODIC,
+ ),
outOfQuotaPolicy = extractOutOfQuotaPolicyFromCall(call),
- payload = extractPayload(call)
+ payload = extractPayload(call),
)
}
PossibleWorkManagerCall.IS_SCHEDULED_BY_UNIQUE_NAME -> {
WorkManagerCall.IsScheduled.ByUniqueName(
- call.argument(IS_SCHEDULED_UNIQUE_NAME_KEY)!!
+ call.argument(IS_SCHEDULED_UNIQUE_NAME_KEY)!!,
)
}
- PossibleWorkManagerCall.CANCEL_TASK_BY_UNIQUE_NAME -> WorkManagerCall.CancelTask.ByUniqueName(
- call.argument(UNREGISTER_TASK_UNIQUE_NAME_KEY)!!
- )
- PossibleWorkManagerCall.CANCEL_TASK_BY_TAG -> WorkManagerCall.CancelTask.ByTag(
- call.argument(
- UNREGISTER_TASK_TAG_KEY
- )!!
- )
+ PossibleWorkManagerCall.CANCEL_TASK_BY_UNIQUE_NAME ->
+ WorkManagerCall.CancelTask.ByUniqueName(
+ call.argument(UNREGISTER_TASK_UNIQUE_NAME_KEY)!!,
+ )
+ PossibleWorkManagerCall.CANCEL_TASK_BY_TAG ->
+ WorkManagerCall.CancelTask.ByTag(
+ call.argument(
+ UNREGISTER_TASK_TAG_KEY,
+ )!!,
+ )
PossibleWorkManagerCall.CANCEL_ALL -> WorkManagerCall.CancelTask.All
PossibleWorkManagerCall.UNKNOWN -> WorkManagerCall.Unknown
@@ -261,7 +265,7 @@ object Extractor {
private fun extractExistingWorkPolicyFromCall(call: MethodCall): ExistingWorkPolicy =
try {
ExistingWorkPolicy.valueOf(
- call.argument(REGISTER_TASK_EXISTING_WORK_POLICY_KEY)!!.uppercase()
+ call.argument(REGISTER_TASK_EXISTING_WORK_POLICY_KEY)!!.uppercase(),
)
} catch (ignored: Exception) {
defaultOneOffExistingWorkPolicy
@@ -271,8 +275,8 @@ object Extractor {
try {
ExistingPeriodicWorkPolicy.valueOf(
call.argument(
- REGISTER_TASK_EXISTING_WORK_POLICY_KEY
- )!!.uppercase()
+ REGISTER_TASK_EXISTING_WORK_POLICY_KEY,
+ )!!.uppercase(),
)
} catch (ignored: Exception) {
defaultPeriodExistingWorkPolicy
@@ -280,41 +284,42 @@ object Extractor {
private fun extractFrequencySecondsFromCall(call: MethodCall) =
call.argument(PERIODIC_TASK_FREQUENCY_SECONDS_KEY)?.toLong()
- ?: defaultPeriodicRefreshFrequencyInSeconds
+ ?: DEFAULT_PERIODIC_REFRESH_FREQUENCY_SECONDS
private fun extractFlexIntervalSecondsFromCall(call: MethodCall) =
call.argument(PERIODIC_FLEX_INTERVAL_SECONDS_KEY)?.toLong()
- ?: defaultFlexIntervalInSeconds
+ ?: DEFAULT_FLEX_INTERVAL_SECONDS
private fun extractInitialDelayFromCall(call: MethodCall) =
call.argument(REGISTER_TASK_INITIAL_DELAY_SECONDS_KEY)?.toLong()
- ?: defaultInitialDelaySeconds
+ ?: DEFAULT_INITIAL_DELAY_SECONDS
private fun extractBackoffPolicyConfigFromCall(
call: MethodCall,
- taskType: TaskType
+ taskType: TaskType,
): BackoffPolicyTaskConfig? {
if (call.argument(REGISTER_TASK_BACK_OFF_POLICY_TYPE_KEY) == null) {
return null
}
- val backoffPolicy = try {
- BackoffPolicy.valueOf(
- call.argument(REGISTER_TASK_BACK_OFF_POLICY_TYPE_KEY)!!.uppercase()
- )
- } catch (ignored: Exception) {
- defaultBackOffPolicy
- }
+ val backoffPolicy =
+ try {
+ BackoffPolicy.valueOf(
+ call.argument(REGISTER_TASK_BACK_OFF_POLICY_TYPE_KEY)!!.uppercase(),
+ )
+ } catch (ignored: Exception) {
+ defaultBackOffPolicy
+ }
val requestedBackoffDelay =
call.argument(REGISTER_TASK_BACK_OFF_POLICY_DELAY_MILLIS_KEY)?.toLong()
- ?: defaultRequestedBackoffDelay
+ ?: DEFAULT_REQUESTED_BACKOFF_DELAY
val minimumBackOffDelay = taskType.minimumBackOffDelay
return BackoffPolicyTaskConfig(
backoffPolicy,
requestedBackoffDelay,
- minimumBackOffDelay
+ minimumBackOffDelay,
)
}
@@ -322,7 +327,7 @@ object Extractor {
fun extractOutOfQuotaPolicyFromCall(call: MethodCall): OutOfQuotaPolicy? {
try {
return OutOfQuotaPolicy.valueOf(
- call.argument(REGISTER_TASK_OUT_OF_QUOTA_POLICY_KEY)!!.uppercase()
+ call.argument(REGISTER_TASK_OUT_OF_QUOTA_POLICY_KEY)!!.uppercase(),
)
} catch (ignored: Exception) {
return defaultOutOfQuotaPolicy
@@ -334,7 +339,7 @@ object Extractor {
fun extractNetworkTypeFromCall(call: MethodCall) =
try {
NetworkType.valueOf(
- call.argument(REGISTER_TASK_CONSTRAINTS_NETWORK_TYPE_KEY)!!.uppercase()
+ call.argument(REGISTER_TASK_CONSTRAINTS_NETWORK_TYPE_KEY)!!.uppercase(),
)
} catch (ignored: Exception) {
defaultNetworkType
@@ -344,10 +349,12 @@ object Extractor {
val requiresBatteryNotLow =
call.argument(REGISTER_TASK_CONSTRAINTS_BATTERY_NOT_LOW_KEY)
?: false
- val requiresCharging = call.argument(REGISTER_TASK_CONSTRAINTS_CHARGING_KEY)
- ?: false
- val requiresDeviceIdle = call.argument(REGISTER_TASK_CONSTRAINTS_DEVICE_IDLE_KEY)
- ?: false
+ val requiresCharging =
+ call.argument(REGISTER_TASK_CONSTRAINTS_CHARGING_KEY)
+ ?: false
+ val requiresDeviceIdle =
+ call.argument(REGISTER_TASK_CONSTRAINTS_DEVICE_IDLE_KEY)
+ ?: false
val requiresStorageNotLow =
call.argument(REGISTER_TASK_CONSTRAINTS_STORAGE_NOT_LOW_KEY)
?: false
diff --git a/android/src/main/kotlin/dev/fluttercommunity/workmanager/SharedPreferenceHelper.kt b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/SharedPreferenceHelper.kt
similarity index 88%
rename from android/src/main/kotlin/dev/fluttercommunity/workmanager/SharedPreferenceHelper.kt
rename to workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/SharedPreferenceHelper.kt
index 0f13a08d..f0202e09 100644
--- a/android/src/main/kotlin/dev/fluttercommunity/workmanager/SharedPreferenceHelper.kt
+++ b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/SharedPreferenceHelper.kt
@@ -3,12 +3,15 @@ package dev.fluttercommunity.workmanager
import android.content.Context
object SharedPreferenceHelper {
-
private const val SHARED_PREFS_FILE_NAME = "flutter_workmanager_plugin"
private const val CALLBACK_DISPATCHER_HANDLE_KEY = "be.tramckrijte.workmanager.CALLBACK_DISPATCHER_HANDLE_KEY"
+
private fun Context.prefs() = getSharedPreferences(SHARED_PREFS_FILE_NAME, Context.MODE_PRIVATE)
- fun saveCallbackDispatcherHandleKey(ctx: Context, callbackHandle: Long) {
+ fun saveCallbackDispatcherHandleKey(
+ ctx: Context,
+ callbackHandle: Long,
+ ) {
ctx.prefs()
.edit()
.putLong(CALLBACK_DISPATCHER_HANDLE_KEY, callbackHandle)
@@ -16,7 +19,6 @@ object SharedPreferenceHelper {
}
fun getCallbackHandle(ctx: Context): Long {
-
return ctx.prefs().getLong(CALLBACK_DISPATCHER_HANDLE_KEY, -1L)
}
diff --git a/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerCallHandler.kt b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerCallHandler.kt
similarity index 67%
rename from android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerCallHandler.kt
rename to workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerCallHandler.kt
index 0f964240..3b12de86 100644
--- a/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerCallHandler.kt
+++ b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerCallHandler.kt
@@ -18,40 +18,53 @@ import io.flutter.plugin.common.MethodChannel
import java.util.concurrent.TimeUnit
private fun Context.workManager() = WorkManager.getInstance(this)
+
private fun MethodChannel.Result.success() = success(true)
private interface CallHandler {
- fun handle(context: Context, convertedCall: T, result: MethodChannel.Result)
+ fun handle(
+ context: Context,
+ convertedCall: T,
+ result: MethodChannel.Result,
+ )
}
class WorkmanagerCallHandler(private val ctx: Context) : MethodChannel.MethodCallHandler {
- override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
+ override fun onMethodCall(
+ call: MethodCall,
+ result: MethodChannel.Result,
+ ) {
when (val extractedCall = Extractor.extractWorkManagerCallFromRawMethodName(call)) {
- is WorkManagerCall.Initialize -> InitializeHandler.handle(
- ctx,
- extractedCall,
- result
- )
- is WorkManagerCall.RegisterTask -> RegisterTaskHandler.handle(
- ctx,
- extractedCall,
- result
- )
- is WorkManagerCall.IsScheduled -> IsScheduledHandler.handle(
- ctx,
- extractedCall,
- result
- )
- is WorkManagerCall.CancelTask -> UnregisterTaskHandler.handle(
- ctx,
- extractedCall,
- result
- )
- is WorkManagerCall.Failed -> FailedTaskHandler(extractedCall.code).handle(
- ctx,
- extractedCall,
- result
- )
+ is WorkManagerCall.Initialize ->
+ InitializeHandler.handle(
+ ctx,
+ extractedCall,
+ result,
+ )
+ is WorkManagerCall.RegisterTask ->
+ RegisterTaskHandler.handle(
+ ctx,
+ extractedCall,
+ result,
+ )
+ is WorkManagerCall.IsScheduled ->
+ IsScheduledHandler.handle(
+ ctx,
+ extractedCall,
+ result,
+ )
+ is WorkManagerCall.CancelTask ->
+ UnregisterTaskHandler.handle(
+ ctx,
+ extractedCall,
+ result,
+ )
+ is WorkManagerCall.Failed ->
+ FailedTaskHandler(extractedCall.code).handle(
+ ctx,
+ extractedCall,
+ result,
+ )
is WorkManagerCall.Unknown -> UnknownTaskHandler.handle(ctx, extractedCall, result)
}
}
@@ -61,11 +74,11 @@ private object InitializeHandler : CallHandler {
override fun handle(
context: Context,
convertedCall: WorkManagerCall.Initialize,
- result: MethodChannel.Result
+ result: MethodChannel.Result,
) {
SharedPreferenceHelper.saveCallbackDispatcherHandleKey(
context,
- convertedCall.callbackDispatcherHandleKey
+ convertedCall.callbackDispatcherHandleKey,
)
result.success()
}
@@ -75,7 +88,7 @@ private object RegisterTaskHandler : CallHandler {
override fun handle(
context: Context,
convertedCall: WorkManagerCall.RegisterTask,
- result: MethodChannel.Result
+ result: MethodChannel.Result,
) {
if (!SharedPreferenceHelper.hasCallbackHandle(context)) {
result.error(
@@ -90,24 +103,25 @@ private object RegisterTaskHandler : CallHandler {
"\n" +
"\n" +
"The `callbackDispatcher` is a top level function. See example in repository.",
- null
+ null,
)
return
}
when (convertedCall) {
is WorkManagerCall.RegisterTask.OneOffTask -> enqueueOneOffTask(context, convertedCall)
- is WorkManagerCall.RegisterTask.PeriodicTask -> enqueuePeriodicTask(
- context,
- convertedCall
- )
+ is WorkManagerCall.RegisterTask.PeriodicTask ->
+ enqueuePeriodicTask(
+ context,
+ convertedCall,
+ )
}
result.success()
}
private fun enqueuePeriodicTask(
context: Context,
- convertedCall: WorkManagerCall.RegisterTask.PeriodicTask
+ convertedCall: WorkManagerCall.RegisterTask.PeriodicTask,
) {
WM.enqueuePeriodicTask(
context = context,
@@ -122,13 +136,13 @@ private object RegisterTaskHandler : CallHandler {
constraintsConfig = convertedCall.constraintsConfig,
backoffPolicyConfig = convertedCall.backoffPolicyConfig,
outOfQuotaPolicy = convertedCall.outOfQuotaPolicy,
- payload = convertedCall.payload
+ payload = convertedCall.payload,
)
}
private fun enqueueOneOffTask(
context: Context,
- convertedCall: WorkManagerCall.RegisterTask.OneOffTask
+ convertedCall: WorkManagerCall.RegisterTask.OneOffTask,
) {
WM.enqueueOneOffTask(
context = context,
@@ -141,7 +155,7 @@ private object RegisterTaskHandler : CallHandler {
constraintsConfig = convertedCall.constraintsConfig,
backoffPolicyConfig = convertedCall.backoffPolicyConfig,
outOfQuotaPolicy = convertedCall.outOfQuotaPolicy,
- payload = convertedCall.payload
+ payload = convertedCall.payload,
)
}
}
@@ -150,13 +164,14 @@ private object IsScheduledHandler : CallHandler {
override fun handle(
context: Context,
convertedCall: WorkManagerCall.IsScheduled,
- result: MethodChannel.Result
+ result: MethodChannel.Result,
) {
when (convertedCall) {
is WorkManagerCall.IsScheduled.ByUniqueName -> {
val workInfos = WM.getWorkInfoByUniqueName(context, convertedCall.uniqueName).get()
- val scheduled = workInfos.isNotEmpty()
- && workInfos.all { it.state == WorkInfo.State.ENQUEUED || it.state == WorkInfo.State.RUNNING }
+ val scheduled =
+ workInfos.isNotEmpty() &&
+ workInfos.all { it.state == WorkInfo.State.ENQUEUED || it.state == WorkInfo.State.RUNNING }
return result.success(scheduled)
}
}
@@ -167,13 +182,14 @@ private object UnregisterTaskHandler : CallHandler {
override fun handle(
context: Context,
convertedCall: WorkManagerCall.CancelTask,
- result: MethodChannel.Result
+ result: MethodChannel.Result,
) {
when (convertedCall) {
- is WorkManagerCall.CancelTask.ByUniqueName -> WM.cancelByUniqueName(
- context,
- convertedCall.uniqueName
- )
+ is WorkManagerCall.CancelTask.ByUniqueName ->
+ WM.cancelByUniqueName(
+ context,
+ convertedCall.uniqueName,
+ )
is WorkManagerCall.CancelTask.ByTag -> WM.cancelByTag(context, convertedCall.tag)
WorkManagerCall.CancelTask.All -> WM.cancelAll(context)
}
@@ -185,7 +201,7 @@ class FailedTaskHandler(private val code: String) : CallHandler {
override fun handle(
context: Context,
convertedCall: WorkManagerCall.Unknown,
- result: MethodChannel.Result
+ result: MethodChannel.Result,
) {
result.notImplemented()
}
@@ -210,29 +226,30 @@ object WM {
tag: String? = null,
isInDebugMode: Boolean = false,
existingWorkPolicy: ExistingWorkPolicy = defaultOneOffExistingWorkPolicy,
- initialDelaySeconds: Long = defaultInitialDelaySeconds,
+ initialDelaySeconds: Long = DEFAULT_INITIAL_DELAY_SECONDS,
constraintsConfig: Constraints = defaultConstraints,
outOfQuotaPolicy: OutOfQuotaPolicy? = defaultOutOfQuotaPolicy,
- backoffPolicyConfig: BackoffPolicyTaskConfig?
+ backoffPolicyConfig: BackoffPolicyTaskConfig?,
) {
- val oneOffTaskRequest = OneTimeWorkRequest.Builder(BackgroundWorker::class.java)
- .setInputData(buildTaskInputData(dartTask, isInDebugMode, payload))
- .setInitialDelay(initialDelaySeconds, TimeUnit.SECONDS)
- .setConstraints(constraintsConfig)
- .apply {
- if (backoffPolicyConfig != null) {
- setBackoffCriteria(
- backoffPolicyConfig.backoffPolicy,
- backoffPolicyConfig.backoffDelay,
- TimeUnit.MILLISECONDS
- )
+ val oneOffTaskRequest =
+ OneTimeWorkRequest.Builder(BackgroundWorker::class.java)
+ .setInputData(buildTaskInputData(dartTask, isInDebugMode, payload))
+ .setInitialDelay(initialDelaySeconds, TimeUnit.SECONDS)
+ .setConstraints(constraintsConfig)
+ .apply {
+ if (backoffPolicyConfig != null) {
+ setBackoffCriteria(
+ backoffPolicyConfig.backoffPolicy,
+ backoffPolicyConfig.backoffDelay,
+ TimeUnit.MILLISECONDS,
+ )
+ }
}
- }
- .apply {
- tag?.let(::addTag)
- outOfQuotaPolicy?.let(::setExpedited)
- }
- .build()
+ .apply {
+ tag?.let(::addTag)
+ outOfQuotaPolicy?.let(::setExpedited)
+ }
+ .build()
context.workManager()
.enqueueUniqueWork(uniqueName, existingWorkPolicy, oneOffTaskRequest)
}
@@ -243,14 +260,14 @@ object WM {
dartTask: String,
payload: String? = null,
tag: String? = null,
- frequencyInSeconds: Long = defaultPeriodicRefreshFrequencyInSeconds,
- flexIntervalInSeconds:Long = defaultFlexIntervalInSeconds,
+ frequencyInSeconds: Long = DEFAULT_PERIODIC_REFRESH_FREQUENCY_SECONDS,
+ flexIntervalInSeconds: Long = DEFAULT_FLEX_INTERVAL_SECONDS,
isInDebugMode: Boolean = false,
existingWorkPolicy: ExistingPeriodicWorkPolicy = defaultPeriodExistingWorkPolicy,
- initialDelaySeconds: Long = defaultInitialDelaySeconds,
+ initialDelaySeconds: Long = DEFAULT_INITIAL_DELAY_SECONDS,
constraintsConfig: Constraints = defaultConstraints,
outOfQuotaPolicy: OutOfQuotaPolicy? = defaultOutOfQuotaPolicy,
- backoffPolicyConfig: BackoffPolicyTaskConfig?
+ backoffPolicyConfig: BackoffPolicyTaskConfig?,
) {
val periodicTaskRequest =
PeriodicWorkRequest.Builder(
@@ -258,7 +275,7 @@ object WM {
frequencyInSeconds,
TimeUnit.SECONDS,
flexIntervalInSeconds,
- TimeUnit.SECONDS
+ TimeUnit.SECONDS,
)
.setInputData(buildTaskInputData(dartTask, isInDebugMode, payload))
.setInitialDelay(initialDelaySeconds, TimeUnit.SECONDS)
@@ -268,7 +285,7 @@ object WM {
setBackoffCriteria(
backoffPolicyConfig.backoffPolicy,
backoffPolicyConfig.backoffDelay,
- TimeUnit.MILLISECONDS
+ TimeUnit.MILLISECONDS,
)
}
}
@@ -284,7 +301,7 @@ object WM {
private fun buildTaskInputData(
dartTask: String,
isInDebugMode: Boolean,
- payload: String?
+ payload: String?,
): Data {
return Data.Builder()
.putString(DART_TASK_KEY, dartTask)
@@ -297,12 +314,20 @@ object WM {
.build()
}
- fun getWorkInfoByUniqueName(context: Context, uniqueWorkName: String) =
- context.workManager().getWorkInfosForUniqueWork(uniqueWorkName)
+ fun getWorkInfoByUniqueName(
+ context: Context,
+ uniqueWorkName: String,
+ ) = context.workManager().getWorkInfosForUniqueWork(uniqueWorkName)
+
+ fun cancelByUniqueName(
+ context: Context,
+ uniqueWorkName: String,
+ ) = context.workManager().cancelUniqueWork(uniqueWorkName)
- fun cancelByUniqueName(context: Context, uniqueWorkName: String) =
- context.workManager().cancelUniqueWork(uniqueWorkName)
+ fun cancelByTag(
+ context: Context,
+ tag: String,
+ ) = context.workManager().cancelAllWorkByTag(tag)
- fun cancelByTag(context: Context, tag: String) = context.workManager().cancelAllWorkByTag(tag)
fun cancelAll(context: Context) = context.workManager().cancelAllWork()
}
diff --git a/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt
similarity index 91%
rename from android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt
rename to workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt
index 4ec1db6f..e81b07dc 100644
--- a/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt
+++ b/workmanager/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt
@@ -6,7 +6,6 @@ import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.MethodChannel
class WorkmanagerPlugin : FlutterPlugin {
-
private var methodChannel: MethodChannel? = null
private var workmanagerCallHandler: WorkmanagerCallHandler? = null
@@ -14,7 +13,10 @@ class WorkmanagerPlugin : FlutterPlugin {
onAttachedToEngine(binding.applicationContext, binding.binaryMessenger)
}
- private fun onAttachedToEngine(context: Context, messenger: BinaryMessenger) {
+ private fun onAttachedToEngine(
+ context: Context,
+ messenger: BinaryMessenger,
+ ) {
workmanagerCallHandler = WorkmanagerCallHandler(context)
methodChannel = MethodChannel(messenger, "be.tramckrijte.workmanager/foreground_channel_work_manager")
methodChannel?.setMethodCallHandler(workmanagerCallHandler)
diff --git a/workmanager/android/src/test/java/ExtractorTests.kt b/workmanager/android/src/test/java/ExtractorTests.kt
new file mode 100644
index 00000000..48ef123e
--- /dev/null
+++ b/workmanager/android/src/test/java/ExtractorTests.kt
@@ -0,0 +1,54 @@
+import androidx.work.NetworkType
+import androidx.work.OutOfQuotaPolicy
+import dev.fluttercommunity.workmanager.Extractor
+import io.flutter.plugin.common.MethodCall
+import org.junit.Assert.assertEquals
+import org.junit.Test
+
+class ExtractorTests {
+ @Test
+ fun shouldParseOutOfQuotaPolicyFromCall() {
+ val all =
+ mapOf(
+ null to null,
+ "drop_work_request" to OutOfQuotaPolicy.DROP_WORK_REQUEST,
+ "run_as_non_expedited_work_request" to
+ OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST,
+ )
+
+ all.forEach { (dartString, wmConstant) ->
+ val call =
+ MethodCall(
+ "",
+ mapOf("outOfQuotaPolicy" to dartString),
+ )
+ assertEquals(Extractor.extractOutOfQuotaPolicyFromCall(call), wmConstant)
+ }
+ }
+
+ @Test
+ fun shouldParseNetworkTypeFromCall() {
+ val all =
+ mapOf(
+ "unmetered" to NetworkType.UNMETERED,
+ "metered" to NetworkType.METERED,
+ "not_required" to NetworkType.NOT_REQUIRED,
+ "not_roaming" to NetworkType.NOT_ROAMING,
+ "temporarily_unmetered" to NetworkType.TEMPORARILY_UNMETERED,
+ "connected" to NetworkType.CONNECTED,
+ )
+
+ all.forEach { (dartString, wmConstant) ->
+ val call =
+ MethodCall(
+ "",
+ mapOf(
+ "networkType" to dartString,
+ ),
+ )
+ val constraints = Extractor.extractConstraintConfigFromCall(call)
+
+ assertEquals(constraints.requiredNetworkType, wmConstant)
+ }
+ }
+}
diff --git a/ios/.gitignore b/workmanager/ios/.gitignore
similarity index 100%
rename from ios/.gitignore
rename to workmanager/ios/.gitignore
diff --git a/ios/Assets/.gitkeep b/workmanager/ios/Assets/.gitkeep
similarity index 100%
rename from ios/Assets/.gitkeep
rename to workmanager/ios/Assets/.gitkeep
diff --git a/ios/Classes/BackgroundTaskOperation.swift b/workmanager/ios/Classes/BackgroundTaskOperation.swift
similarity index 99%
rename from ios/Classes/BackgroundTaskOperation.swift
rename to workmanager/ios/Classes/BackgroundTaskOperation.swift
index d832f139..42028092 100644
--- a/ios/Classes/BackgroundTaskOperation.swift
+++ b/workmanager/ios/Classes/BackgroundTaskOperation.swift
@@ -24,7 +24,6 @@ class BackgroundTaskOperation: Operation {
self.backgroundMode = backgroundMode
}
-
override func main() {
let semaphore = DispatchSemaphore(value: 0)
let worker = BackgroundWorker(mode: self.backgroundMode,
diff --git a/ios/Classes/BackgroundWorker.swift b/workmanager/ios/Classes/BackgroundWorker.swift
similarity index 99%
rename from ios/Classes/BackgroundWorker.swift
rename to workmanager/ios/Classes/BackgroundWorker.swift
index a6aee7d8..843f4c4d 100644
--- a/ios/Classes/BackgroundWorker.swift
+++ b/workmanager/ios/Classes/BackgroundWorker.swift
@@ -113,7 +113,7 @@ class BackgroundWorker {
backgroundMethodChannel?.invokeMethod(
BackgroundChannel.onResultSendCommand,
- arguments:arguments,
+ arguments: arguments,
result: { flutterResult in
cleanupFlutterResources()
let taskSessionCompleter = Date()
diff --git a/ios/Classes/CheckBackgroundRefreshPermission.swift b/workmanager/ios/Classes/CheckBackgroundRefreshPermission.swift
similarity index 100%
rename from ios/Classes/CheckBackgroundRefreshPermission.swift
rename to workmanager/ios/Classes/CheckBackgroundRefreshPermission.swift
diff --git a/ios/Classes/DebugNotificationHelper.swift b/workmanager/ios/Classes/DebugNotificationHelper.swift
similarity index 100%
rename from ios/Classes/DebugNotificationHelper.swift
rename to workmanager/ios/Classes/DebugNotificationHelper.swift
diff --git a/ios/Classes/Extensions.swift b/workmanager/ios/Classes/Extensions.swift
similarity index 100%
rename from ios/Classes/Extensions.swift
rename to workmanager/ios/Classes/Extensions.swift
diff --git a/ios/Classes/NetworkType.swift b/workmanager/ios/Classes/NetworkType.swift
similarity index 100%
rename from ios/Classes/NetworkType.swift
rename to workmanager/ios/Classes/NetworkType.swift
diff --git a/ios/Classes/SimpleLogger.swift b/workmanager/ios/Classes/SimpleLogger.swift
similarity index 100%
rename from ios/Classes/SimpleLogger.swift
rename to workmanager/ios/Classes/SimpleLogger.swift
diff --git a/ios/Classes/SwiftWorkmanagerPlugin.swift b/workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift
similarity index 99%
rename from ios/Classes/SwiftWorkmanagerPlugin.swift
rename to workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift
index 03ed3e40..80b6de6c 100644
--- a/ios/Classes/SwiftWorkmanagerPlugin.swift
+++ b/workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift
@@ -148,7 +148,7 @@ public class SwiftWorkmanagerPlugin: FlutterPluginAppLifeCycleDelegate {
/// Immediately starts a one off task
@available(iOS 13.0, *)
- public static func startOneOffTask(identifier: String, taskIdentifier: UIBackgroundTaskIdentifier, inputData:String, delaySeconds: Int64) {
+ public static func startOneOffTask(identifier: String, taskIdentifier: UIBackgroundTaskIdentifier, inputData: String, delaySeconds: Int64) {
let operationQueue = OperationQueue()
// Create an operation that performs the main part of the background task
let operation = BackgroundTaskOperation(
@@ -332,7 +332,6 @@ extension SwiftWorkmanagerPlugin: FlutterPlugin {
let inputData =
arguments[method.Arguments.inputData.rawValue] as? String
-
taskIdentifier = UIApplication.shared.beginBackgroundTask(withName: uniqueTaskIdentifier, expirationHandler: {
// Mark the task as ended if time is expired, otherwise iOS might terminate and will throttle future executions
UIApplication.shared.endBackgroundTask(taskIdentifier)
diff --git a/ios/Classes/ThumbnailGenerator.swift b/workmanager/ios/Classes/ThumbnailGenerator.swift
similarity index 100%
rename from ios/Classes/ThumbnailGenerator.swift
rename to workmanager/ios/Classes/ThumbnailGenerator.swift
diff --git a/ios/Classes/UserDefaultsHelper.swift b/workmanager/ios/Classes/UserDefaultsHelper.swift
similarity index 100%
rename from ios/Classes/UserDefaultsHelper.swift
rename to workmanager/ios/Classes/UserDefaultsHelper.swift
diff --git a/ios/Classes/WMPError.swift b/workmanager/ios/Classes/WMPError.swift
similarity index 100%
rename from ios/Classes/WMPError.swift
rename to workmanager/ios/Classes/WMPError.swift
diff --git a/ios/Classes/WorkmanagerPlugin.h b/workmanager/ios/Classes/WorkmanagerPlugin.h
similarity index 100%
rename from ios/Classes/WorkmanagerPlugin.h
rename to workmanager/ios/Classes/WorkmanagerPlugin.h
diff --git a/ios/Classes/WorkmanagerPlugin.m b/workmanager/ios/Classes/WorkmanagerPlugin.m
similarity index 100%
rename from ios/Classes/WorkmanagerPlugin.m
rename to workmanager/ios/Classes/WorkmanagerPlugin.m
diff --git a/ios/workmanager.podspec b/workmanager/ios/workmanager.podspec
similarity index 100%
rename from ios/workmanager.podspec
rename to workmanager/ios/workmanager.podspec
diff --git a/lib/src/options.dart b/workmanager/lib/src/options.dart
similarity index 100%
rename from lib/src/options.dart
rename to workmanager/lib/src/options.dart
diff --git a/lib/src/workmanager.dart b/workmanager/lib/src/workmanager.dart
similarity index 99%
rename from lib/src/workmanager.dart
rename to workmanager/lib/src/workmanager.dart
index 2faad2de..74951fdc 100644
--- a/lib/src/workmanager.dart
+++ b/workmanager/lib/src/workmanager.dart
@@ -278,13 +278,14 @@ class Workmanager {
/// Checks whether a period task is scheduled by its [uniqueName].
///
/// Scheduled means the work state is either ENQUEUED or RUNNING
- ///
+ ///
/// Only available on Android.
Future isScheduledByUniqueName(final String uniqueName) async {
- return await _foregroundChannel.invokeMethod(
+ return await _foregroundChannel.invokeMethod(
"isScheduledByUniqueName",
{"uniqueName": uniqueName},
);
+ }
/// Schedule a background long running task, currently only available on iOS.
///
@@ -424,7 +425,7 @@ class JsonMapperHelper {
"taskName": taskName,
"tag": tag,
"frequency": frequency?.inSeconds,
- "flexInterval":flexInterval?.inSeconds,
+ "flexInterval": flexInterval?.inSeconds,
"existingWorkPolicy": _enumToString(existingWorkPolicy),
"initialDelaySeconds": initialDelay?.inSeconds,
"networkType": _enumToString(constraints?.networkType),
diff --git a/lib/workmanager.dart b/workmanager/lib/workmanager.dart
similarity index 100%
rename from lib/workmanager.dart
rename to workmanager/lib/workmanager.dart
diff --git a/workmanager/pubspec.yaml b/workmanager/pubspec.yaml
new file mode 100644
index 00000000..8fbc2298
--- /dev/null
+++ b/workmanager/pubspec.yaml
@@ -0,0 +1,32 @@
+name: workmanager
+description: Flutter Workmanager. This plugin allows you to schedule background work on Android and iOS.
+version: 0.5.2
+homepage: https://github.com/fluttercommunity/flutter_workmanager
+repository: https://github.com/fluttercommunity/flutter_workmanager
+issue_tracker: https://github.com/fluttercommunity/flutter_workmanager/issues
+
+environment:
+ sdk: '>=3.1.2 <4.0.0'
+ flutter: ">=2.5.0"
+
+dependencies:
+ flutter:
+ sdk: flutter
+
+dev_dependencies:
+ build_runner: ^2.1.7
+ test: ^1.16.3
+ mockito: ^5.0.4
+ get_it: ^7.2.0
+ flutter_test:
+ sdk: flutter
+ flutter_lints: ^2.0.1
+
+flutter:
+ plugin:
+ platforms:
+ android:
+ package: dev.fluttercommunity.workmanager
+ pluginClass: WorkmanagerPlugin
+ ios:
+ pluginClass: WorkmanagerPlugin
diff --git a/test/json_mapper_helper_test.dart b/workmanager/test/json_mapper_helper_test.dart
similarity index 99%
rename from test/json_mapper_helper_test.dart
rename to workmanager/test/json_mapper_helper_test.dart
index 924a70dd..44742e0a 100644
--- a/test/json_mapper_helper_test.dart
+++ b/workmanager/test/json_mapper_helper_test.dart
@@ -48,7 +48,7 @@ void main() {
'uniqueName': 'uniqueName',
'taskName': 'taskName',
'tag': null,
- 'flexInterval':null,
+ 'flexInterval': null,
'frequency': null,
'existingWorkPolicy': null,
'initialDelaySeconds': null,
@@ -189,7 +189,6 @@ void main() {
'tag': null,
'frequency': null,
'flexInterval': null,
-
'existingWorkPolicy': null,
'initialDelaySeconds': 1,
'networkType': 'connected',
@@ -218,7 +217,6 @@ void main() {
'tag': null,
'frequency': null,
'flexInterval': null,
-
'existingWorkPolicy': null,
'initialDelaySeconds': 1,
'networkType': 'metered',
@@ -241,7 +239,6 @@ void main() {
'tag': null,
'frequency': null,
'flexInterval': null,
-
'existingWorkPolicy': null,
'initialDelaySeconds': 1,
'networkType': 'metered',
@@ -270,7 +267,6 @@ void main() {
'tag': null,
'frequency': null,
'flexInterval': null,
-
'existingWorkPolicy': null,
'initialDelaySeconds': 1,
'networkType': 'not_roaming',
@@ -299,7 +295,6 @@ void main() {
'tag': null,
'frequency': null,
'flexInterval': null,
-
'existingWorkPolicy': null,
'initialDelaySeconds': 1,
'networkType': 'unmetered',
@@ -354,7 +349,6 @@ void main() {
'tag': null,
'frequency': null,
'flexInterval': null,
-
'existingWorkPolicy': existingWorkPolicy[1],
'initialDelaySeconds': 1,
'networkType': null,
diff --git a/test/workmanager_test.dart b/workmanager/test/workmanager_test.dart
similarity index 79%
rename from test/workmanager_test.dart
rename to workmanager/test/workmanager_test.dart
index 4fd7615c..44a98ca7 100644
--- a/test/workmanager_test.dart
+++ b/workmanager/test/workmanager_test.dart
@@ -21,16 +21,14 @@ void mySetUpWrapper() {
@GenerateMocks([Workmanager])
void main() {
- group(
- "singleton pattern",
- () => {
- test("It always return the same workmanager instance", () {
- final workmanager = Workmanager();
- final workmanager2 = Workmanager();
-
- expect(workmanager == workmanager2, true);
- })
- });
+ group("singleton pattern", () {
+ test("It always return the same workmanager instance", () {
+ final workmanager = Workmanager();
+ final workmanager2 = Workmanager();
+
+ expect(workmanager == workmanager2, true);
+ });
+ });
group("mocked workmanager", () {
setUpAll(() {
diff --git a/test/workmanager_test.mocks.dart b/workmanager/test/workmanager_test.mocks.dart
similarity index 77%
rename from test/workmanager_test.mocks.dart
rename to workmanager/test/workmanager_test.mocks.dart
index f784fd73..b973630a 100644
--- a/test/workmanager_test.mocks.dart
+++ b/workmanager/test/workmanager_test.mocks.dart
@@ -27,12 +27,17 @@ class MockWorkmanager extends _i1.Mock implements _i2.Workmanager {
@override
void executeTask(_i2.BackgroundTaskHandler? backgroundTask) =>
- super.noSuchMethod(Invocation.method(#executeTask, [backgroundTask]), returnValueForMissingStub: null);
+ super.noSuchMethod(Invocation.method(#executeTask, [backgroundTask]),
+ returnValueForMissingStub: null);
@override
- _i3.Future initialize(Function? callbackDispatcher, {bool? isInDebugMode = false}) =>
- (super.noSuchMethod(Invocation.method(#initialize, [callbackDispatcher], {#isInDebugMode: isInDebugMode}),
- returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i3.Future);
+ _i3.Future initialize(Function? callbackDispatcher,
+ {bool? isInDebugMode = false}) =>
+ (super.noSuchMethod(
+ Invocation.method(#initialize, [callbackDispatcher],
+ {#isInDebugMode: isInDebugMode}),
+ returnValue: Future.value(),
+ returnValueForMissingStub: Future.value()) as _i3.Future);
@override
_i3.Future registerOneOffTask(String? uniqueName, String? taskName,
@@ -92,16 +97,20 @@ class MockWorkmanager extends _i1.Mock implements _i2.Workmanager {
returnValueForMissingStub: Future.value()) as _i3.Future);
@override
- _i3.Future cancelByUniqueName(String? uniqueName) => (super.noSuchMethod(Invocation.method(#cancelByUniqueName, [uniqueName]),
- returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i3.Future);
+ _i3.Future cancelByUniqueName(String? uniqueName) =>
+ (super.noSuchMethod(Invocation.method(#cancelByUniqueName, [uniqueName]),
+ returnValue: Future.value(),
+ returnValueForMissingStub: Future.value()) as _i3.Future);
@override
_i3.Future cancelByTag(String? tag) =>
- (super.noSuchMethod(Invocation.method(#cancelByTag, [tag]), returnValue: Future.value(), returnValueForMissingStub: Future.value())
- as _i3.Future);
+ (super.noSuchMethod(Invocation.method(#cancelByTag, [tag]),
+ returnValue: Future.value(),
+ returnValueForMissingStub: Future.value()) as _i3.Future);
@override
_i3.Future cancelAll() =>
- (super.noSuchMethod(Invocation.method(#cancelAll, []), returnValue: Future.value(), returnValueForMissingStub: Future.value())
- as _i3.Future);
+ (super.noSuchMethod(Invocation.method(#cancelAll, []),
+ returnValue: Future.value(),
+ returnValueForMissingStub: Future.value()) as _i3.Future);
}