License: MIT Build Status

This a library to simplify islate thread communication. It abstracts the data transfer between islate and the main thread into a simple channel, and the channel only needs to listen for data changes and close the channel, thus simplifying the data communication of islate.


  • channel abstraction.
  • Data Listening.
  • Message Channel Close event.

Getting started

start using the package.


import 'package:wuchuheng_isolate_channel/src/service/task/index.dart';
import 'package:wuchuheng_isolate_channel/wuchuheng_isolate_channel.dart';
import 'package:wuchuheng_logger/wuchuheng_logger.dart';

void main() async {
    /// Isolate logic code.
    final Task task = await IsolateTask((message, channel) {'isolate: receive $message');
        channel.send('task data');
        channel.onClose((name) =>'Channel is closed. channel: $name.'));

    ///Main thread code.
    final channel = task.createChannel(name: 'channelName')
        ..listen((message, channel) =>'Receiving isolate messages')).cancel();
    channel.send('Send data to isolate');
    await Future.delayed(Duration(seconds: 1));

    ///Turn off the channel

    /// listen to future
    final task2 = await IsolateTask((message, channel) {
    final channel2 = task2.createChannel();
    final result = channel2.listenToFuture();
    print(await result); // print 2


Additional information

contribute to the package, how to file issues, what response they can expect from the package authors, and more.


View Github