IsolateRunner class

A utility class for running operations in isolates.

This class provides a simple way to run operations in separate isolates, which can help improve performance for CPU-intensive tasks by avoiding blocking the main thread.

Constructors

IsolateRunner.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

run<T, R>({required R function(T), required T message}) Future<R>
Runs a function in an isolate.
runBatch<T, R>({required R function(T), required List<T> items, int batchSize = 50}) Future<List<R>>
Runs a batch of operations in an isolate.
runWithThreshold<T, R>({required R function(T), required T message, required int dataSize, int asyncThreshold = defaultAsyncThreshold}) Future<R>
Runs a function in an isolate if the data size exceeds the threshold.

Constants

defaultAsyncThreshold → const int
The default threshold (in bytes) above which operations will be performed in a separate isolate.