I'm writing some code for Flutter Desktop targeting linux_x64.
I'm extracting some logs from some applications, these logs presents a syntax like this:
Inspecting log file using
less logfile
ESC(BESC[mauthentication-msESC(BESC[m
Inspecting log file using
less -r logfile
I can see colored text into my terminal.Inspecting log file using
cat logfile
I can see colored text into my terminal.Inspecting log file using
cat -vte logfile
I get this:^[(B^[[mauthentication-ms^[(B^[[m$
In Flutter using this code
Future<String> readAsString = file.readAsString(); readAsString.then((String value) => _log = utf8.decode(value.runes.toList()));
I get this output in a SelectableText widget
(B[mauthentication-ms(B[m
I'm really confused about this behaviour so if someone has experience on this suggestions are welcome!
There are 2 options:
- Cleaning all the logs, visualizing normal text
- Trying to decode the text just as
less -r
does, visualizing colored text into Flutter application.
EDIT:
I solved importing tint plugin: tint: ^2.0.0
and changing the Dart code (using the strip()
method from tint plugin) as follows:
Future<String> readAsString = file.readAsString();
readAsString.then((String value) => _log = value.strip());