By design this project is meant to display in the LogView widget the contents that would be printed in the launcher process stdout
. That is achieved by having the launcher redirecting its output to a pipe whose read end is inherited as the stdin
of this Flutter app.
When building the proof of concept I noticed a fairly consistent behavior of stdin.transform(systemEncoding.decoder)
stream interpreting line breaks just after the first character. I did some investigation on the C++ side, but nothing was conclusive enough, so I preferred to perform this quick fix and investigate further later on, since I don't really have a clue about what causes that behavior at this point after the first investigation steps being done.
The fix implemented in the POC was just adding some more state to an already stateful widget. The need for state is what motivates writting a transformer class instead of just a function.
As demonstrated in the test file it is meant to be passed straight into stdin.transform()
.
void _transformerAssert(
{required Iterable<String> input, required Iterable<String> output}) {
final fakeStdin = StreamController<List<int>>();
final stringStdin = Stream.fromIterable(input);
fakeStdin.addStream(stringStdin.transform(systemEncoding.encoder));
final resultStream = fakeStdin.stream.transform(StdinTransformer());
expect(resultStream, emitsInOrder(output));
}