dartssh2
dartssh2 copied to clipboard
adding streams only suitable if shell is available
how
i incorporated this from the docs
final shell = await client.shell();
stdout.addStream(shell.stdout); // listening for stdout
stderr.addStream(shell.stderr); // listening for stderr
stdin.cast<Uint8List>().listen(shell.write); // writing to stdin
await shell.done; // wait for shell to exit
client.close();
what
- run app from CLI -> no problems
- run app via double clicking on .exe ->
FileSystemException: Error retrieving socket type, path = " (OS Error: The handle is invalid., errno = 6)
solution
import 'package:flutter/foundation.dart';
final shell = await client.shell();
if (kDebugMode) {
stdout.addStream(shell.stdout); // listening for stdout
stderr.addStream(shell.stderr); // listening for stderr
stdin.cast<Uint8List>().listen(shell.write); // writing to stdin
}
await shell.done; // wait for shell to exit
client.close();
this works because I know the end users will only be running a release version, but I would like to know if there is a better way to prevent the error