startIsolateLoop method

void startIsolateLoop(
  1. String id,
  2. FutureOr<void> body(), {
  3. Duration? delay,
  4. String? debugName,
  5. bool permanent = false,
})

Starts a sequential loop in a separate isolate.

Constraint: The body must be a top-level function or a static method. Closures that capture state cannot be sent across isolate boundaries.

Implementation

void startIsolateLoop(
  String id,
  FutureOr<void> Function() body, {
  Duration? delay,
  String? debugName,
  bool permanent = false,
}) {
  final service =
      _IsolateLoopService(body, delay: delay, debugName: debugName);
  registerService(id, service, permanent: permanent);
  service.start();
}