eseunghwan / python_shell.dart

Python Environment Manager and Executor for dart and flutter
MIT License
3 stars 3 forks source link

retrieve data from inside the shell #2

Closed guyluz11 closed 1 year ago

guyluz11 commented 1 year ago

Is there an option to retrieve data from inside the shell?.

guyluz11 commented 1 year ago

Found it

I need to insert methods to a shell listener

ShellListener output = ShellListener(
    onMessage: (String a) {
      print('On message $a');
    },
    onComplete: () {
      print('On complete ');
    },
    onError: (object, stackTrace) {
      print('Error object:$object\nstackTrace:$stackTrace');
    },
  );

and then insert this shell listener into the function

 await instance.runString(
    """
    python code .......................
""",
    echo: true,
    listener: output,
  );