on dispose kill isolate
This commit is contained in:
parent
1a59b72815
commit
cbab08f072
|
@ -57,6 +57,8 @@ class CwtchFfi implements Cwtch {
|
|||
ProfileListState profileCN;
|
||||
CwtchNotifier cwtchNotifier;
|
||||
|
||||
Isolate cwtchIsolate;
|
||||
|
||||
CwtchFfi(ProfileListState profs) {
|
||||
library = DynamicLibrary.open("libCwtch.so");
|
||||
profileCN = profs;
|
||||
|
@ -81,7 +83,7 @@ class CwtchFfi implements Cwtch {
|
|||
|
||||
// Test non timer getting events from libcwtch-go
|
||||
var _receivePort = ReceivePort();
|
||||
var _isolate = await Isolate.spawn(_checkAppbusEvents, _receivePort.sendPort);
|
||||
cwtchIsolate = await Isolate.spawn(_checkAppbusEvents, _receivePort.sendPort);
|
||||
_receivePort.listen((message) {
|
||||
var env = jsonDecode(message);
|
||||
cwtchNotifier.handleMessage(env["EventType"], env["Data"]);
|
||||
|
@ -89,6 +91,13 @@ class CwtchFfi implements Cwtch {
|
|||
|
||||
//repaintProfileStream = pollRepaintProfileEvents();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
if (cwtchIsolate != null) {
|
||||
cwtchIsolate.kill();
|
||||
}
|
||||
}
|
||||
/*
|
||||
Stream<bool> GetRepaintProfileStream() {
|
||||
return repaintProfileStream;
|
||||
|
|
Loading…
Reference in New Issue