Skip to content

Commit 6ed2944

Browse files
authored
Merge pull request #83 from devmil/bugfix/isolate_example_gh82
fixes Issue #82
2 parents c814cb8 + dab4d27 commit 6ed2944

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

example/lib/isolate.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,23 @@ class MyHomePage extends StatefulWidget {
4343
}
4444

4545
class FakeTerminalBackend extends TerminalBackend {
46-
final _exitCodeCompleter = Completer<int>();
46+
// we do a late initialization of those backend members as the backend gets
47+
// transferred into the Isolate.
48+
// It is not allowed to e.g. transfer closures which we can not guarantee
49+
// to not exist in our member types.
50+
// The Isolate will call init() once it starts (from its context) and that is
51+
// the place where we initialize those members
52+
late final _exitCodeCompleter;
4753
// ignore: close_sinks
48-
final _outStream = StreamController<String>();
54+
late final _outStream;
4955

5056
@override
5157
Future<int> get exitCode => _exitCodeCompleter.future;
5258

5359
@override
5460
void init() {
61+
_exitCodeCompleter = Completer<int>();
62+
_outStream = StreamController<String>();
5563
_outStream.sink.add('xterm.dart demo');
5664
_outStream.sink.add('\r\n');
5765
_outStream.sink.add('\$ ');

0 commit comments

Comments
 (0)