Skip to content

Releases: brewkits/native_workmanager

v1.0.8 — DartWorker iOS fix, path traversal hardening, Koin hot restart

07 Mar 05:04

Choose a tag to compare

What's Fixed

  • iOS: DartWorker works in debug / integration-test modeFlutterCallbackCache returns nil in JIT builds; fixed by routing through the existing main method channel instead of a secondary engine. All iOS integration tests now pass.
  • iOS: DartWorker callback input correctly decoded — input was wrapped as {'raw': '...'} instead of the actual decoded map; callbacks now receive {'key': 'value'} as expected.
  • iOS: False disk-space failure on small downloads — removed the fixed 50 MB constant from hasEnoughDiskSpace(); formula now matches Android: requiredBytes × 1.2.
  • iOS: Chain cancel handle stored before executionhandleEnqueueChain now stores the Task handle in activeTasks before starting, so cancel() finds it correctly.
  • iOS: Chain enqueue was blocking — returns "ACCEPTED" immediately; result delivered via EventChannel.
  • iOS: Data race on taskStartTimes — all reads/writes now use stateQueue with .barrier writes.
  • Android: Hot restart skipped Koin reloadisKoinInitialized now reset in onDetachedFromEngine().
  • Android: Path traversal hardened — replaced contains("..") with File.canonicalPath across all 7 workers.
  • Android: HttpDownloadWorker null body NPEresponse.body!! replaced with explicit null check.
  • Dart: TaskEvent null-safety — replaced unsafe casts with null-safe fallbacks.
  • Dart: TaskEvent.operator== ignored message — fixed equality to include message field.
  • README: API examples corrected — all 9 code sample inaccuracies fixed against the actual Dart API.

Version Alignment

pubspec.yaml, native_workmanager.podspec, and android/build.gradle all set to 1.0.8.

Full changelog

v1.0.7 — Fix iOS custom workers (input never reached doWork)

03 Mar 17:15
c26ea4e

Choose a tag to compare

What's Fixed

Critical: iOS custom workers silently failed since initial implementation

NativeWorker.custom(className:, input:) on iOS — the user-supplied input dictionary was never passed to doWork(). Root cause: executeWorkerSync() serialised the full internal workerConfig (which contains workerType, className, and the input as a nested JSON string) instead of extracting and passing the pre-encoded input payload. Custom workers received wrapper fields instead of their own parameters, so every parameter lookup returned nil and every task silently failed.

Fix: Extract workerConfig["input"] as? String when present; fall back to full config for built-in workers. Applied to both the foreground path (executeWorkerSync) and the background path (BGTaskSchedulerManager.executeWorker).

What's Improved

  • doc/use-cases/07-custom-native-workers.md: corrected return types (Boolean/BoolWorkerResult), fixed Android registration hook, iOS @main + import native_workmanager, broken file reference
  • README.md: custom-worker row in comparison table + full showcase section with Kotlin/Swift/Dart examples
  • Demo app: Custom Workers tab now runs real NativeWorker.custom() calls
  • Integration tests: Group 10 "Custom Native Workers" — 3 new tests (32 total passing)
  • SimpleAndroidWorkerFactory: Log.e for unknown class instead of silent null

Upgrade

flutter pub upgrade native_workmanager

Full changelog: CHANGELOG.md

v1.0.6

28 Feb 11:14

Choose a tag to compare

v1.0.6 — Thread Safety, SDK Constraint, Topics

Fixed

  • Android: Thread safetytaskTags, taskStatuses, taskStartTimes replaced with ConcurrentHashMap (NativeWorkmanagerPlugin.kt)

    • mutableMapOf() (LinkedHashMap) is not thread-safe; concurrent coroutine access could silently corrupt data or throw ConcurrentModificationException under load
  • iOS: Memory safetyonTaskComplete closure now captures instance weakly (NativeWorkmanagerPlugin.swift)

    • BGTaskSchedulerManager.shared.onTaskComplete implicitly captured the plugin instance strongly; the adjacent progressDelegate already used [weak instance] correctly

Changed

  • Topics addedbackground, workmanager, networking, files, cryptography for pub.dev discoverability
  • SDK constraintsdk: '>=3.6.0 <4.0.0', flutter: '>=3.27.0' (fixes pub.dev static analysis / "unknown platforms")
  • Lint rulescancel_subscriptions, close_sinks, avoid_returning_null_for_future, always_declare_return_types and more

Upgrade

native_workmanager: ^1.0.6

v1.0.5 - Trigger/Constraint Correctness, SPM Support, QA Fixes

26 Feb 15:24

Choose a tag to compare

v1.0.5 — Trigger/Constraint Correctness, SPM Support, QA Fixes

Added

  • Swift Package Manager (SPM) support for iOS — works with both SPM and CocoaPods

    • Added ios/native_workmanager/Package.swift with binaryTarget for the bundled KMPWorkManager XCFramework and ZIPFoundation dependency
    • Moved Swift sources to ios/native_workmanager/Sources/native_workmanager/ (Flutter SPM layout)
    • Resolves partial pub.dev platform score for SPM support
  • Device integration test suite — GROUP 1–9 covering all trigger types, ExistingPolicy, all 11 workers, chains, tags, cancellation, events, progress, and DartWorker constraint & delay enforcement


Fixed (Critical — Android periodic tasks)

  • Trigger type hardcoded to OneTime — periodic/exact/windowed triggers were silently ignored (NativeWorkmanagerPlugin.kt)

    • Every task was treated as one-shot. Periodic tasks only ran once; exact/windowed triggers were completely ineffective
    • Full trigger parsing now switches on the "type" key and creates the correct TaskTrigger subtype
  • ExistingTaskPolicy hardcoded to KEEP — users could not replace existing tasks

  • Constraints hardcoded to defaultsrequiresNetwork, requiresCharging, backoffPolicy, isHeavyTask, and systemConstraints were silently ignored

  • Periodic tasks stopped emitting events after first executionFlow.first {} unsubscribed after first terminal state

    • Periodic tasks now use takeWhile { state != CANCELLED }.collect {}

Fixed (iOS)

  • flexMs key lookup used wrong name flexIntervalMs — flex window always nil
  • Constraints ignored qos and exactAlarmIOSBehavior
  • Chain resume dropped all worker config values — all config lost after app kill
  • Initial task state set to "running" instead of "pending"
  • Custom worker registration always silently skipped#if canImport(ClassName) is always false
  • IosWorker protocol and IosWorkerFactory were internal — host apps could not register custom workers
  • WorkerError undefined; WorkerResult.success(data:) wrong type in example

Fixed (QA round)

  • Android: CancellationException swallowed in 3 Flow-collection coroutines — coroutines leaked on plugin detach
  • Android: HttpDownloadWorker deleted temp file on network error — broke resume
  • Android: ImageProcessWorker sampleSize could be 0maxOf(1, min(...)) prevents zero sample size
  • iOS: CryptoWorker loaded file before size check — OOM crash on large files fixed; random salt now used instead of hardcoded string

Upgrade

dependencies:
  native_workmanager: ^1.0.5

v1.0.4 - WorkManager 2.10.0+ Compatibility Fix

17 Feb 17:59

Choose a tag to compare

🐛 Critical Bug Fix

Android: Worker crash "IllegalStateException: Not implemented" - FIXED

The Problem

All Android users were experiencing crashes when using WorkManager 2.10.0+:

IllegalStateException: Not implemented
  at androidx.work.CoroutineWorker.getForegroundInfo(CoroutineWorker.kt:92)

The Solution

✅ Upgraded to kmpworkmanager 2.3.3 which adds proper getForegroundInfo() override
✅ Now safe to use with work-runtime-ktx 2.10.1+
✅ Includes notification i18n support and chain routing fixes

Impact: All expedited tasks now work without crashing on WorkManager 2.10.0+


🎯 What's Fixed

Core Fixes

  • Android crash fix: Proper getForegroundInfo() implementation for expedited tasks
  • Chain routing fix: Heavy tasks (isHeavyTask=true) now correctly use KmpHeavyWorker
  • Notification i18n: Notification strings now support localization via Android resources

Example App Improvements

  • ✅ Added interactive Bug Fix Demo tab proving WorkManager 2.10.0+ compatibility
  • ✅ Added comprehensive integration tests for bug verification
  • ✅ Fixed Flutter rendering error in Chain Resilience Test screen
  • ✅ Fixed integration test API usage
  • ✅ Corrected competitor library naming in benchmarks

Documentation

  • 📄 Complete bug fix verification guide (BUG_FIX_VERIFICATION.md)
  • 📄 Migration guide (no code changes required - just upgrade!)

📦 Dependencies Updated

  • kmpworkmanager: 2.3.1 → 2.3.3 (fixes WorkManager 2.10.0+ compatibility)
  • work-runtime-ktx: 2.9.1 → 2.10.1 (safe with kmpworkmanager 2.3.3+)

🚀 Migration Guide

No code changes required! Just upgrade:

dependencies:
  native_workmanager: ^1.0.4  # was ^1.0.3

Then:

flutter pub get
flutter clean
flutter build apk

🙏 Credits

Special thanks to Abdullah Al-Hasnat for reporting this critical bug and providing detailed reproduction steps.


📊 Verification

  • ✅ All 808 tests passing
  • ✅ Android build verified from Maven Central
  • ✅ iOS build verified
  • ✅ Bug fix demo confirms no crashes
  • ✅ Integration tests validate WorkManager 2.10.0+ compatibility

All users should upgrade to v1.0.4 immediately.

v1.0.3 - Critical Android Fix

16 Feb 16:14

Choose a tag to compare

🔴 CRITICAL FIX - Android Users Must Upgrade

Bug Fixed

  • Android: Fixed IllegalStateException: KmpWorkManager not initialized!
  • Impact: Versions 1.0.0, 1.0.1, and 1.0.2 were completely non-functional on Android
  • Root Cause: Plugin was missing KmpWorkManager.initialize() call

What Changed

// Added in NativeWorkmanagerPlugin.kt
KmpWorkManager.initialize(
    context = context,
    workerFactory = SimpleAndroidWorkerFactory(context),
    config = KmpWorkManagerConfig()
)

Upgrade Instructions

  1. Update pubspec.yaml:
    dependencies:
      native_workmanager: ^1.0.3
  2. Run:
    flutter pub get
    flutter clean

New Documentation

Acknowledgments

Reported by: Abdullah Al-Hasnat

iOS Status

✅ iOS not affected - no changes needed


All Android users should upgrade immediately.

v1.0.2 - Critical Android Fix

16 Feb 16:13

Choose a tag to compare

🔴 CRITICAL FIX - Android Users Must Upgrade

Bug Fixed

  • Android: Fixed IllegalStateException: KmpWorkManager not initialized!
  • Impact: Versions 1.0.0 and 1.0.1 were completely non-functional on Android
  • Root Cause: Plugin was missing KmpWorkManager.initialize() call

What Changed

// Added in NativeWorkmanagerPlugin.kt
KmpWorkManager.initialize(
    context = context,
    workerFactory = SimpleAndroidWorkerFactory(context),
    config = KmpWorkManagerConfig()
)

Upgrade Instructions

  1. Update pubspec.yaml:
    dependencies:
      native_workmanager: ^1.0.2
  2. Run:
    flutter pub get
    flutter clean

New Documentation

Acknowledgments

Reported by: Abdullah Al-Hasnat - Thank you for the detailed error report!

iOS Status

✅ iOS not affected - no changes needed


All Android users should upgrade immediately.

v1.0.1 - Pub.dev Compliance Fix

12 Feb 17:19

Choose a tag to compare

🎯 Native WorkManager v1.0.1 - Pub.dev Compliance Fix

Metadata improvement to achieve perfect pub.dev score (160/160 points).

🔧 What Changed

Fixed

  • Package Description: Shortened from 215 to 154 characters
  • Compliance: Now meets pub.dev requirement (60-180 chars)
  • Score Impact: 150/160 → 160/160 points

📊 Before vs After

Metric v1.0.0 v1.0.1 Status
Description Length 215 chars 154 chars ✅ Fixed
Pub Points 150/160 160/160 ✅ Perfect
Compliance Failed Passed ✅ Full

📝 Details

This is a metadata-only release with no code changes. It addresses the package description length issue identified in pub.dev's automated analysis of v1.0.0.

Old Description (215 chars):

"Native background task manager for Flutter. Zero Flutter Engine overhead. 50MB less memory, 5x faster startup. Built on kmpworkmanager v2.3.1 (Android + iOS) with critical bug fixes, security hardening, Koin scope isolation, and iOS chain reliability improvements."

New Description (154 chars):

"Native background task manager for Flutter. Zero Flutter Engine overhead. 50MB less memory, 5x faster startup. Built on kmpworkmanager v2.3.1."

The shortened description maintains all key value propositions while meeting pub.dev's publishing guidelines.

🚀 Installation

dependencies:
  native_workmanager: ^1.0.1

🔗 Links


Note: All features and functionality from v1.0.0 remain unchanged. This release only improves package metadata for better pub.dev compliance.

v1.0.0 - Production Ready

12 Feb 17:14

Choose a tag to compare

🚀 Native WorkManager v1.0.0 - Production Ready

Native background task manager for Flutter with zero Flutter Engine overhead.

📊 Performance Improvements

Compared to standard Flutter background solutions:

Metric native_workmanager flutter_workmanager Improvement
RAM Usage 35 MB 85 MB 58% less
Startup Time 70 ms 525 ms 7.5x faster
Engine Overhead 0 MB ~50 MB Zero

✨ Key Features

11 Built-in Native Workers

Execute common tasks in pure Kotlin/Swift without loading the Flutter Engine:

  • HTTP Operations: Request, Sync, Download, Upload (with resume support)
  • File Operations: Copy, Move, Delete, Zip, Unzip
  • Media Processing: Image resize/compress
  • Cryptography: Hash, Encrypt, Decrypt
  • Dart Fallback: Custom logic with engine caching & auto-dispose

Task Chains

Automate multi-step workflows entirely in native code:

await NativeWorkManager.beginWith(
  TaskRequest(
    id: 'download',
    worker: HttpDownloadWorker(
      url: 'https://cdn.example.com/data.zip',
      savePath: '/tmp/data.zip',
      supportResume: true,
    ),
  ),
).then(
  TaskRequest(
    id: 'unzip',
    worker: FileDecompressionWorker(
      inputPath: '/tmp/data.zip',
      outputPath: '/tmp/extracted/',
    ),
  ),
).enqueue();

Benefits:

  • Auto-retry with exponential backoff
  • Resume support for long-running tasks
  • Survives app restarts (persisted state)
  • Automatic dependency management

🔒 Production Quality

Testing & Validation

  • 808 passing tests (unit, integration, performance)
  • 150/160 pub points on pub.dev
  • ✅ Security validations (path traversal, URL filtering, file size limits)
  • ✅ Memory leak testing with LeakCanary

Documentation

  • 25+ comprehensive guides
  • 15+ interactive demo examples
  • 7 real-world use cases
  • Complete API reference

Platform Support

  • iOS: 12.0+ (BGTaskScheduler)
  • Android: API 21+ (WorkManager)
  • Full platform feature parity

🛠 What's New in v1.0.0

iOS Improvements

  • Eliminated all unsafe force unwraps (zero crash risk)
  • Enhanced error handling with guard statements
  • Chain data flow with state persistence
  • Auto-resume after app kill

Android Improvements

  • Optimized engine lifecycle management
  • Improved WorkManager integration
  • Better resource cleanup

API Improvements

  • Shortened package description for pub.dev compliance
  • Improved error messages
  • Better TypeScript-style API documentation

Testing Improvements

  • Added proper platform channel mocking
  • Fixed chain data flow test initialization
  • 13 new passing tests

📦 Installation

dependencies:
  native_workmanager: ^1.0.0

Then run:

flutter pub get

🔗 Links

💬 Feedback

Found a bug or have a feature request? Open an issue

🙏 Acknowledgments

Built on kmpworkmanager v2.3.1 - a battle-tested KMP wrapper around WorkManager (Android) and BGTaskScheduler (iOS).


Full Changelog: https://github.com/brewkits/native_workmanager/blob/main/CHANGELOG.md