Shell commands in Flutter
2,019
Flutter doesn't yet support multiple windows, so currently if you want to do that you'd have to do it via native code, controlled via platform channels.
Author by
Admin
Updated on December 20, 2022Comments
-
Admin over 1 year
I am developing a desktop UI in Flutter and I need to create buttons to execute shell commands.
I already can execute some commands simple such as
ls -l
and it shows its results nicely in the console.However I need a way to show the results in the main app and not in the console, I have tried the snackbar but it is not so nice and it does not get the outputs from other commands that gives dynamic outputs.
I would like to watch dynamic outputs such as
tail -f
andtop
.How could I open a new window in the flutter app to show the execution of a command?
For now, I have this:
class LsButton extends StatelessWidget { @override Widget build(BuildContext context) { return Center( child: RaisedButton( onPressed: () { Process.run('ls', ['-l']).then((ProcessResult results) { Flushbar( title: "Output", message: results.stdout, duration: Duration(seconds: 15), )..show(context); }); }, child: Text('Show dir contents!', style: TextStyle( fontSize: 10, ),) ), ); }}