Skip to content

chore: Modernize plugin to v0.7.0 for latest Flutter/Dart versions #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -11,12 +11,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v1
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true

- name: build
run: |
@@ -31,6 +33,7 @@ jobs:
- uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true

- name: build
run: |
52 changes: 40 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -14,10 +14,14 @@ jobs:
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Install melos
run: dart pub global activate melos
- name: Bootstrap packages
run: melos bootstrap
- name: Test
run: |
cd workmanager
flutter pub get
flutter test

native_ios_tests:
@@ -27,25 +31,36 @@ jobs:
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Install melos
run: dart pub global activate melos
- name: Bootstrap packages
run: melos bootstrap
- name: Build iOS App
run: cd example && flutter build ios --debug --no-codesign
- name: Run native iOS tests
run: cd example/ios && xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' test
run: cd example/ios && xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' test

native_android_tests:
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v1
- uses: actions/setup-java@v4
with:
java-version: 17
- uses: subosito/flutter-action@v1
distribution: 'temurin'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Install melos
run: dart pub global activate melos
- name: Bootstrap packages
run: melos bootstrap
- name: Build Android App
run: cd example && flutter build apk --debug
- name: Run native Android tests
run: cd example/android && gradle workmanager:test
run: cd example/android && ./gradlew :workmanager:test

drive_ios:
strategy:
@@ -55,13 +70,18 @@ jobs:
fail-fast: false
runs-on: macos-latest
steps:
- uses: futureware-tech/simulator-action@v1
with:
model: '${{ matrix.device }}'
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- uses: futureware-tech/simulator-action@v3
with:
model: '${{ matrix.device }}'
- name: Install melos
run: dart pub global activate melos
- name: Bootstrap packages
run: melos bootstrap
# Run flutter integrate tests
- name: Run Flutter integration tests
run: cd example && flutter test integration_test/workmanager_integration_test.dart
@@ -73,7 +93,7 @@ jobs:
strategy:
#set of different configurations of the virtual environment.
matrix:
api-level: [29]
api-level: [34]
# api-level: [21, 29]
target: [default]
steps:
@@ -86,13 +106,21 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: '17'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Install melos
run: dart pub global activate melos
- name: Bootstrap packages
run: melos bootstrap
- name: Run Flutter Driver tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: x86_64
disk-size: 6000M
heap-size: 600M
script: cd example && flutter test integration_test/workmanager_integration_test.dart
2 changes: 2 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
2 changes: 2 additions & 0 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -24,6 +24,8 @@ if (flutterVersionName == null) {
}

android {
ndkVersion "27.0.12077973"
Copy link
Preview

Copilot AI Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example app uses NDK version 27.0.12077973, but the plugin metadata mentions NDK 26.3.11579264. Consider aligning these versions across plugin and example for consistency.

Suggested change
ndkVersion "27.0.12077973"
ndkVersion "26.3.11579264"

Copilot uses AI. Check for mistakes.


sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri May 30 01:37:19 JST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '12.0'
platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
12 changes: 6 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -37,12 +37,12 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
integration_test: 13825b8a9334a850581300559b8839134b124670
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
workmanager: 0afdcf5628bbde6924c21af7836fed07b42e30e6
integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e
path_provider_foundation: 608fcb11be570ce83519b076ab6a1fffe2474f05
permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d
shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7
workmanager: b89e4e4445d8b57ee2fdbf1c3925696ebe5b8990

PODFILE CHECKSUM: b63d507eb7cc768afa26646638aaf07f371f6370

COCOAPODS: 1.14.3
COCOAPODS: 1.16.2
12 changes: 6 additions & 6 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -513,7 +513,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
@@ -601,7 +601,7 @@
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -652,7 +652,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
@@ -735,7 +735,7 @@
DEVELOPMENT_TEAM = GPGRWN6G4J;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = RunnerTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -767,7 +767,7 @@
DEVELOPMENT_TEAM = GPGRWN6G4J;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = RunnerTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -796,7 +796,7 @@
DEVELOPMENT_TEAM = GPGRWN6G4J;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = RunnerTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
@@ -53,11 +54,13 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
9 changes: 5 additions & 4 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -3,16 +3,17 @@ description: Demonstrates how to use the workmanager plugin.
publish_to: 'none'

environment:
sdk: '>=3.1.2 <4.0.0'
sdk: ">=3.2.0 <4.0.0"

dependencies:
path_provider:
shared_preferences:
permission_handler:
path_provider: ^2.1.5
shared_preferences: ^2.3.0
permission_handler: ^11.3.1
flutter:
sdk: flutter
workmanager:


dev_dependencies:
integration_test:
sdk: flutter
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: workmanager_workspace

environment:
sdk: '>=2.17.0 <3.0.0'
sdk: '>=3.2.0 <4.0.0'
dev_dependencies:
melos: ^5.3.0
melos: ^6.0.0
19 changes: 19 additions & 0 deletions workmanager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# 0.7.0

* **BREAKING**: Minimum Dart SDK bumped to 3.2.0
* **BREAKING**: Minimum Flutter SDK bumped to 3.16.0
* **BREAKING**: Minimum iOS deployment target bumped to 13.0
* Android: Update to Android Gradle Plugin 8.10.1
* Android: Update to Gradle 8.11.1
* Android: Update Kotlin to 2.1.0
* Android: Update compile SDK to 35
* Android: Update target SDK to 35
* Android: Update NDK to 27.0.12077973
* Android: Update Java compatibility to version 17
* iOS: Update Swift version to 5.0
* Dev dependencies: Update to latest versions (flutter_lints 5.0.0, mockito 5.4.4, etc.)
* CI: Modernize GitHub Actions workflows with latest action versions
* CI: Add Flutter caching for faster builds
* CI: Update test environments (iPhone 15, Android API 34)
* Fix win32 dependency compatibility issues for Dart 3.8+

# 0.6.0

* Android: Removed jetifier
2 changes: 1 addition & 1 deletion workmanager/android/build.gradle
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ android {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
compileSdk 34
compileSdk 35
minSdkVersion 19
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
5 changes: 3 additions & 2 deletions workmanager/ios/workmanager.podspec
Original file line number Diff line number Diff line change
@@ -16,7 +16,8 @@ Flutter Android Workmanager
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'

s.ios.deployment_target = '10.0'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
s.ios.deployment_target = '13.0'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
s.swift_version = '5.0'
end

16 changes: 8 additions & 8 deletions workmanager/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: workmanager
description: Flutter Workmanager. This plugin allows you to schedule background work on Android and iOS.
version: 0.6.0
version: 0.7.0
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"
sdk: '>=3.2.0 <4.0.0'
flutter: ">=3.16.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
build_runner: ^2.4.0
test: ^1.25.0
mockito: ^5.4.4
get_it: ^8.0.0
flutter_test:
sdk: flutter
flutter_lints: ^2.0.1
flutter_lints: ^5.0.0

flutter:
plugin:

Unchanged files with check annotations Beta

private struct ForegroundMethodChannel {
static let channelName = "\(SwiftWorkmanagerPlugin.identifier)/foreground_channel_work_manager"
struct Methods {

Check warning on line 20 in workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift

GitHub Actions / format_swift

Nesting Violation: Types should be nested at most 1 level deep (nesting)
struct Initialize {
static let name = "\(Initialize.self)".lowercasingFirst
enum Arguments: String {
}
// If frequency is not provided it will default to 15 minutes
schedulePeriodicTask(taskIdentifier: task.identifier, earliestBeginInSeconds: earliestBeginInSeconds ?? (15 * 60))

Check warning on line 120 in workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift

GitHub Actions / format_swift

Line Length Violation: Line should be 120 characters or less; currently it has 122 characters (line_length)
let operationQueue = OperationQueue()
// Create an operation that performs the main part of the background task
/// Immediately starts a one off task
@available(iOS 13.0, *)
public static func startOneOffTask(identifier: String, taskIdentifier: UIBackgroundTaskIdentifier, inputData: String, delaySeconds: Int64) {

Check warning on line 147 in workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift

GitHub Actions / format_swift

Line Length Violation: Line should be 120 characters or less; currently it has 144 characters (line_length)
let operationQueue = OperationQueue()
// Create an operation that performs the main part of the background task
let operation = BackgroundTaskOperation(
try BGTaskScheduler.shared.submit(request)
logInfo("BGProcessingTask submitted \(uniqueTaskIdentifier) earliestBeginInSeconds:\(begin)")
} catch {
logInfo("Could not schedule BGProcessingTask identifier:\(uniqueTaskIdentifier) error:\(error.localizedDescription)")

Check warning on line 236 in workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift

GitHub Actions / format_swift

Line Length Violation: Line should be 120 characters or less; currently it has 129 characters (line_length)
logInfo("Possible issues can be: running on a simulator instead of a real device, or the task name is not registered")

Check warning on line 237 in workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift

GitHub Actions / format_swift

Line Length Violation: Line should be 120 characters or less; currently it has 130 characters (line_length)
}
}
let inputData =
arguments[method.Arguments.inputData.rawValue] as? String
taskIdentifier = UIApplication.shared.beginBackgroundTask(withName: uniqueTaskIdentifier, expirationHandler: {

Check warning on line 328 in workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift

GitHub Actions / format_swift

Line Length Violation: Line should be 120 characters or less; currently it has 122 characters (line_length)
// Mark the task as ended if time is expired, otherwise iOS might terminate and will throttle future executions

Check warning on line 329 in workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift

GitHub Actions / format_swift

Line Length Violation: Line should be 120 characters or less; currently it has 127 characters (line_length)
UIApplication.shared.endBackgroundTask(taskIdentifier)
})
SwiftWorkmanagerPlugin.startOneOffTask(identifier: uniqueTaskIdentifier,
} else {
result(FlutterError(code: "99",
message: "PeriodicTask could not be registered",
details: "BGAppRefreshTasks are only supported on iOS 13+. Instead you should use Background Fetch"))

Check warning on line 368 in workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift

GitHub Actions / format_swift

Line Length Violation: Line should be 120 characters or less; currently it has 133 characters (line_length)
}
}
}
print("[BGTaskScheduler] Scheduled Tasks:")
for taskRequest in taskRequests {
print("[BGTaskScheduler] Task Identifier: \(taskRequest.identifier) earliestBeginDate: \(taskRequest.earliestBeginDate?.formatted() ?? "")")

Check warning on line 465 in workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift

GitHub Actions / format_swift

Line Length Violation: Line should be 120 characters or less; currently it has 160 characters (line_length)
}
result(true)
}
return worker.performBackgroundRequest(completionHandler)
}
}

Check warning on line 495 in workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift

GitHub Actions / format_swift

File Length Violation: File should contain 400 lines or less: currently contains 495 (file_length)