Skip to content

adding streams only suitable if shell is available #121

@bradmartin333

Description

@bradmartin333

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

  1. run app from CLI -> no problems
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions