compute
1.0.2, released 4 years ago by dartside.dev
Provides Flutter's compute function for pure Dart programs.
What it does
Exports the compute helper that runs a function in a separate isolate and returns its result. Works on all Dart platforms, including web (where isolates are simulated).
AI-written summary of version 1.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need simple isolate-based background computation in a non‑Flutter Dart app
- You want a drop‑in replacement for Flutter's compute without adding Flutter dependencies
Skip it when
- You require fine‑grained control over isolates or need custom SendPort/ReceivePort handling
- Running on the web where isolates are not truly parallel
Strengths
- Zero Flutter dependency
- Works across all Dart platforms
- Simple API mirroring Flutter's compute
Weaknesses
- No performance gain on web (isolates are simulated)
- Limited to the compute pattern; cannot replace full isolate management
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:compute/compute.dart';
int square(int a) => a * a;
Future<void> main() async {
final result = await compute(square, 5);
print('5^2 = $result');
}Alternatives
Packages that do the same job and could replace compute.
- integral_isolates
Easy to use isolates for Dart and Flutter using a long-lived isolate.
50Compare