flutter_isolate 1.0.0+9

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 79

FlutterIsolate #

FlutterIsolate allows creation of an Isolate in flutter that is able to use flutter plugins. It creates the necessary platform specific bits (FlutterBackgroundView on android & FlutterEngine on iOS) to enable the platoform channels to work inside an isolate.

FlutterIsolate API #

AndroidiOSDescription
FlutterIsolate.spawn(entryPoint,message)spawns a new FlutterIsolate
flutterIsolate.pause()pauses a running isolate
flutterIsolate.resume()resumed a paused isoalte
flutterIsolate.kill()kills a an isolate

Example #

This is available in the example included with the package.

import 'package:flutter_startup/flutter_startup.dart';
import 'package:flutter_isolate/flutter_isolate.dart';

void isolate2(String arg) {
  FlutterStartup.startupReason.then((reason){
    print("Isolate2 $reason");
  });
  Timer.periodic(Duration(seconds:1),(timer)=>print("Timer Running From Isolate 2"));
}

void isolate1(String arg) async  {

  final isolate = await FlutterIsolate.spawn(isolate2, "hello2");

  FlutterStartup.startupReason.then((reason){
    print("Isolate1 $reason");
  });
  Timer.periodic(Duration(seconds:1),(timer)=>print("Timer Running From Isolate 1"));
}

void main() async {

  final isolate = await FlutterIsolate.spawn(isolate1, "hello");
  Timer(Duration(seconds:5), (){print("Pausing Isolate 1");isolate.pause();});
  Timer(Duration(seconds:10),(){print("Resuming Isolate 1");isolate.resume();});
  Timer(Duration(seconds:20),(){print("Killing Isolate 1");isolate.kill();});

  runApp(MyApp());
}
...

Notes #

Due to a FlutterIsolate being backed by a platform specific 'view', the event loop will not terminate when there is no more 'user' work left to do and FlutterIsolates will require explict termination with kill().

Additionally this plugin has not been tested with a large range of plugins, only a small subset I have been using such as flutter_notification, flutter_blue and flutter_startup.

1.0.0 #

  • Initial implementation of an isolate that works with Flutter plugins for android/iOS

example/README.md

FlutterIsolate Example #

Starts an isolate that launches a second isolate. Both call out to a plugin that uses a method channel on both iOS and android to get the startup reason.

The first isolate is paused after 5 seconds, paused after 10, and killed after 20 seconds. The second continues to print forever.

import 'package:flutter_startup/flutter_startup.dart';
import 'package:flutter_isolate/flutter_isolate.dart';

void isolate2(String arg) {
  FlutterStartup.startupReason.then((reason){
    print("Isolate2 $reason");
  });
  Timer.periodic(Duration(seconds:1),(timer)=>print("Timer Running From Isolate 2"));
}

void isolate1(String arg) async  {

  final isolate = await FlutterIsolate.spawn(isolate2, "hello2");

  FlutterStartup.startupReason.then((reason){
    print("Isolate1 $reason");
  });
  Timer.periodic(Duration(seconds:1),(timer)=>print("Timer Running From Isolate 1"));
}

void main() async {

  final isolate = await FlutterIsolate.spawn(isolate1, "hello");
  Timer(Duration(seconds:5), (){print("Pausing Isolate 1");isolate.pause();});
  Timer(Duration(seconds:10),(){print("Resuming Isolate 1");isolate.resume();});
  Timer(Duration(seconds:20),(){print("Killing Isolate 1");isolate.kill();});

  runApp(MyApp());
}
...

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_isolate: ^1.0.0+9

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_isolate/flutter_isolate.dart';
  
Version Uploaded Documentation Archive
1.0.0+9 Mar 9, 2019 Go to the documentation of flutter_isolate 1.0.0+9 Download flutter_isolate 1.0.0+9 archive
1.0.0+8 Mar 9, 2019 Go to the documentation of flutter_isolate 1.0.0+8 Download flutter_isolate 1.0.0+8 archive
1.0.0+7 Feb 24, 2019 Go to the documentation of flutter_isolate 1.0.0+7 Download flutter_isolate 1.0.0+7 archive
1.0.0+6 Feb 20, 2019 Go to the documentation of flutter_isolate 1.0.0+6 Download flutter_isolate 1.0.0+6 archive
1.0.0+5 Feb 20, 2019 Go to the documentation of flutter_isolate 1.0.0+5 Download flutter_isolate 1.0.0+5 archive
1.0.0+4 Feb 19, 2019 Go to the documentation of flutter_isolate 1.0.0+4 Download flutter_isolate 1.0.0+4 archive
1.0.0+3 Feb 19, 2019 Go to the documentation of flutter_isolate 1.0.0+3 Download flutter_isolate 1.0.0+3 archive
1.0.0+2 Feb 19, 2019 Go to the documentation of flutter_isolate 1.0.0+2 Download flutter_isolate 1.0.0+2 archive
1.0.0+1 Feb 19, 2019 Go to the documentation of flutter_isolate 1.0.0+1 Download flutter_isolate 1.0.0+1 archive
1.0.0 Feb 19, 2019 Go to the documentation of flutter_isolate 1.0.0 Download flutter_isolate 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
59
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
79
Learn more about scoring.

We analyzed this package on Mar 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.3.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
uuid ^2.0.0 2.0.0
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8