|
|
@@ -43,15 +43,23 @@ class MyHomePage extends StatefulWidget {
|
|
|
}
|
|
|
|
|
|
class FakeTerminalBackend extends TerminalBackend {
|
|
|
- final _exitCodeCompleter = Completer<int>();
|
|
|
+ // we do a late initialization of those backend members as the backend gets
|
|
|
+ // transferred into the Isolate.
|
|
|
+ // It is not allowed to e.g. transfer closures which we can not guarantee
|
|
|
+ // to not exist in our member types.
|
|
|
+ // The Isolate will call init() once it starts (from its context) and that is
|
|
|
+ // the place where we initialize those members
|
|
|
+ late final _exitCodeCompleter;
|
|
|
// ignore: close_sinks
|
|
|
- final _outStream = StreamController<String>();
|
|
|
+ late final _outStream;
|
|
|
|
|
|
@override
|
|
|
Future<int> get exitCode => _exitCodeCompleter.future;
|
|
|
|
|
|
@override
|
|
|
void init() {
|
|
|
+ _exitCodeCompleter = Completer<int>();
|
|
|
+ _outStream = StreamController<String>();
|
|
|
_outStream.sink.add('xterm.dart demo');
|
|
|
_outStream.sink.add('\r\n');
|
|
|
_outStream.sink.add('\$ ');
|