I have three issues with Process.run that I don't understand.

  1. when I use ps aux in my Linux shell I get a nicely formatted list of processes, when I do it inside Visual Studio I get that as one huge string, I would like to create a data class, so I can map those values. ie MEM CPU, so later I can do myobjec.CPU and I can see how much CPU the process uses with certain PID.

  2. Second problem I would like to monitor this data so that it's updated every 0.5s. But with this technique of me fetching string, formatting string and then outputting that in UI, and doing that every 0.5 seconds sounds insane.

  3. executing something like ps -U \$USER u in Process.run does not work since it outputs an actual string $USER instead of the name of the current user

so far I have two attempts

Future<List<List<String>>> processPlayground() async {
    // This works on Windows/Linux/Mac

    var shell = Shell(workingDirectory: "/");

    List<List<String>> main = [];
    List<Data> dataList = [];
    Data? dt;
    await shell.run('''

 ps -U moonlight u

   ''').then((value) {
      for (var element in value.outLines) {
        main.add(element.replaceAll(_whitespaceRE, " ").split(" ").toList());

    return main;

this works somewhat I have data class where I define, mem, CPU, user and so on and then I format this and present it in flutter UI, but it's very slow, and doing this every 0.5 is inefficient, UI lags.

I have also this :

test() async {
  var process = await Process.start("ps", ["aux"]);
  process.stdout.transform(utf8.decoder).forEach((element) {

tz() {
  mainList.add(sideList[0].replaceAll(_whitespaceRE, " ").split(" ").toList());


But here formatting somehow does not work, but here I also don't run these commands in a shell, don't know if that does make a difference.

TLDR I need a way to get the list of processes, that gets updated every 0.5 seconds with current values, and I need later to have a way to put that in a table for further manipulation. In a similar way that Task Manager on Windows does, or System Monitor on Gnome does.

or should I use a different approach?