Skip to content
pubscout

isolate_pool_executor

2.2.2, released 11 months ago by aymtools.com

Manages a pool of Dart isolates to run CPU‑intensive tasks without blocking the main isolate.

$ flutter pub add isolate_pool_executor
Source repository

What it does

Provides thread‑pool‑like APIs (single, fixed, cached) for creating and reusing isolates. Allows custom core/maximum sizes, keep‑alive times, task queues and rejection policies. Supports passing Flutter tokens for MethodChannel use in isolates.

AI-written summary of version 2.2.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to run heavy CPU‑bound work off the UI thread and want to limit the number of isolates.
  • You want automatic reuse and cleanup of isolates to reduce startup overhead.
  • You need to call platform plugins (e.g., SharedPreferences) from background isolates in Flutter.

Skip it when

  • The work is I/O‑bound and can be handled with simple async Futures.
  • You only need a single isolate via compute() and don’t require pooling.
  • You prefer a widget‑focused solution or need UI components.

Strengths

  • Reduces isolate creation cost by reusing them.
  • Highly configurable pool parameters (core size, max size, keep‑alive, custom handlers).
  • Supports Flutter MethodChannel usage in isolates.

Weaknesses

  • Adds complexity compared to plain compute() or async Futures.
  • Limited to Dart/Flutter; no built‑in task prioritization or scheduling beyond a simple queue.
  • Documentation is concise; advanced features may require reading source code.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0

Requires Flutter SDK >=3.7 for MethodChannel support; just add the package and import it.

import 'package:isolate_pool_executor/isolate_pool_executor.dart';

int _doTask(int count){
  int sum=0;final r=Random();
  for(int i=0;i<count;i++) sum+=r.nextInt(10000);
  return sum;
}

void main() async{
  final pool=IsolatePoolExecutor.newFixedIsolatePool(3);
  final result=await pool.compute(_doTask,1000000);
  print(result);
  pool.shutdown();
}

Alternatives

Packages that do the same job and could replace isolate_pool_executor.

  • async

    Provides basic Future and Stream utilities but lacks isolate pooling; could be used for simple async tasks without extra overhead.