Skip to content
Blog

Background Processing in Flutter: Isolates, WorkManager, and Background Fetch

A decision guide to Flutter background work: short-lived isolates, long-lived workers, WorkManager, BGTaskScheduler, and background_fetch compared.

Published on • November 12, 2026

AI Assistant

Background processing in Flutter is not one feature, it is four tiers with completely different contracts: an isolate that dies when its function returns, a worker isolate you keep alive, an OS scheduler that owns your process, and an opportunistic fetch window. Picking the wrong tier is the difference between a smooth app and one that quietly stops syncing. This is the decision guide across the tiers, not a tutorial for any single package.

The four tiers at a glance

TierTriggerLifetimeSurvives app killTypical use
compute() / Isolate.run()Your codeMillisecondsNoBig JSON parse, image decode
Long-lived isolateYour code, while runningUntil you close itNoContinuous decode pipeline
workmanagerOS schedulerBounded task windowAndroid yes, iOS noSync, upload, cleanup
background_fetchOS, throttledShort burstAndroid headless onlyHeartbeat, feed check

Tier 1: short-lived CPU work

When work takes longer than a frame gap, move it off the main isolate. Isolate.run() spawns, runs one callback, transfers the result, and terminates:

final rows = await Isolate.run(() => decodeRows(rawCsv));

In Flutter you reach for compute(callback, message) instead, which is equivalent on native and runs the callback on the current event loop on web. The spawn cost plus message transfer means sub-millisecond work is a net loss; for that the Flutter docs point at SchedulerBinding.scheduleTask instead. Callbacks must be top-level or static, with a single cheap parameter, as the existing compute isolate processing post details.

Tier 2: long-lived worker isolates

If you run the same computation repeatedly, per-call spawn overhead adds up. Dart’s own guidance is to graduate to Isolate.spawn() with ReceivePort/SendPort pairs:

final initPort = RawReceivePort();
final ready = Completer<(ReceivePort, SendPort)>();
initPort.handler = (msg) {
  ready.complete((
    ReceivePort.fromRawReceivePort(initPort),
    msg as SendPort,
  ));
};
await Isolate.spawn(_workerMain, initPort.sendPort);
final (responses, commands) = await ready.future;

This tier still cannot outlive your app: when the process is backgrounded or killed, the isolate goes with it. It buys parallelism and low-latency message passing while the UI is up, nothing more.

Tier 3: OS-scheduled tasks

Anything that must happen while the app is closed belongs to the OS scheduler, wrapped in Flutter by workmanager (0.10.10 on pub.dev):

@pragma('vm:entry-point')
void callbackDispatcher() {
  Workmanager().executeTask((task, inputData) async {
    await syncInbox();
    return true;
  });
}

await Workmanager().initialize(callbackDispatcher, isInDebugMode: kDebugMode);
await Workmanager().registerOneOffTask('sync-42', 'deltaSync');

On Android this maps to WorkManager, with a hard 15-minute minimum for periodic tasks and the constraint, backoff, and foreground-service options described in the WorkManager background tasks post. On iOS it maps to BGTaskScheduler, where the OS decides whether and when your task runs, and your identifiers must be declared in Info.plist. macOS runs through NSBackgroundActivityScheduler only while the app is running or backgrounded.

Tier 4: opportunistic background fetch

The lightest OS wake-up is background_fetch (1.7.0, Android and iOS only), which never fires faster than every 15 minutes:

final status = await BackgroundFetch.configure(
  BackgroundFetchConfig(minimumFetchInterval: 15, enableHeadless: true),
  (taskId) async {
    try {
      await heartbeat();
    } finally {
      BackgroundFetch.finish(taskId); // never skip this
    }
  },
);

Skipping finish() gets your app penalized: iOS terminates it and cuts future wake frequency, Android throttles the JobScheduler job. The full configure, scheduleTask, and headless-registration contract is covered by the existing background fetch post.

Platform caveats and kill semantics

  • Isolates die with the process. Nothing in tiers 1 or 2 survives termination on any platform.
  • Android WorkManager tasks can survive swipe-away, but OEM battery optimization (Samsung, Xiaomi, Huawei) frequently kills them anyway.
  • iOS has no stopOnTerminate: false. Once the user terminates the app, BGTaskScheduler and background_fetch events stop.
  • iOS background fetch timing can take days of machine learning to settle, and custom scheduleTask jobs tend to fire only while charging.
  • background_fetch on Android can keep running headless after termination; that is the one “survives kill” path outside WorkManager.
  • On Android O and later, connectivity-style broadcasts are not delivered in the background, so re-check state on resume rather than trusting a cached signal.

Choosing a tier

Ask three questions in order. First, does the work need to happen while the app is closed? If no, it is tier 1 or tier 2: Isolate.run() for one-shot jobs, Isolate.spawn() for a persistent pipeline. If yes, does it need constraints, retries, or a guaranteed job slot? Then use workmanager and write the callback as an idempotent, self-contained unit. If all you need is a light periodic ping with no guarantees, background_fetch is the smaller negotiation with the OS. When in doubt, make the work delta-based so a missed run is harmless.

Takeaway: Keep frame-sensitive CPU work in compute() or Isolate.run(), persistent in-process pipelines in a long-lived Isolate.spawn() worker, anything that must run while the app is closed in workmanager (with idempotent callbacks and a release-build test), and light throttled pings in background_fetch with an unconditional finish().

Sources