isolate_utils 2.0.0 copy "isolate_utils: ^2.0.0" to clipboard
isolate_utils: ^2.0.0 copied to clipboard

discontinuedreplaced by: isolate_flutter

IsolateUtils provides a way to launch dart isolate in Flutter (iOS and Android).

IsolateUtils #

Pub

IsolateUtils is a useful package for you who want to make and manage Isolate. It is based on dart:isolate so it only support iOS and Android.

It's like compute(): Spawn an isolate, run callback on that isolate, passing it message, and (eventually) return the value returned by callback. But it not top-level constant so you can create multiple Isolates at the same time.

Usage #

Create and start an isolate #

final _value = await IsolateUtils.createAndStart(_testFunction, 'Hello World');
print(_value);

Create and manager an isolate (not run immediately) #

  1. Create an isolate:

    IsolateUtils _isolateUtils = await IsolateUtils.create(_testFunction, 'Hello World');
    
  2. Start and get the value returned by _testFunction

    final _value = await _isolateUtils.start();
    print(_value);
    
  3. Pause a running isolate

    _isolateUtils.pause();
    
  4. Resume a paused isolate

    _isolateUtils.resume();
    
  5. Stop and dispose a an isolate

    _isolateUtils.stop();
    

Example test function #

static Future<String> _testFunction(String message) async {
    Timer.periodic(Duration(seconds: 1), (timer) => print('$message - ${timer.tick}'));
    await Future.delayed(Duration(seconds: 30));
    return '_testFunction finish';
  }

License #

license_image_url

If you like my project, you can support me Buy Me A Coffee or star (like) for it.

Thank you! ❤️

1
likes
140
pub points
57%
popularity

Publisher

unverified uploader

IsolateUtils provides a way to launch dart isolate in Flutter (iOS and Android).

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on isolate_utils