isolate_worker 0.0.1 copy "isolate_worker: ^0.0.1" to clipboard
isolate_worker: ^0.0.1 copied to clipboard

outdated

A simple IsolateWorker.

example/isolate_worker_example.dart

import 'dart:isolate';

import 'package:isolate_worker/isolate_worker.dart';

void main() async {
  final w = IsolateWorker(toUpper);
  await w.ready;
  final result = await w.sendReceive("hello, world");
  print(result);
  w.kill();
}

toUpper(SendPort sendPort) {
  final rp = ReceivePort();
  sendPort.send(rp.sendPort);
  rp.listen((data) {
    final request = data as Map<String, dynamic>;
    final requestData = request['requestData'] as String;
    final resultPort = request["sendPort"] as SendPort;
    resultPort.send(requestData.toUpperCase());
  });
}
2
likes
20
pub points
38%
popularity

Publisher

unverified uploader

A simple IsolateWorker.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on isolate_worker