pty2 0.5.2 copy "pty2: ^0.5.2" to clipboard
pty2: ^0.5.2 copied to clipboard

Pty2 for Dart and Flutter. Provides the ability to create processes with pseudo terminal file descriptors.

example/pty2.dart

// ignore_for_file: avoid_print

import 'dart:io';
import 'package:pty2/pty2.dart';

void main() async {
  print('Platform: ${Platform.isWindows ? 'pwsh.exe' : 'bash'}');

  final pty = PseudoTerminal.start(
    Platform.isWindows ? 'pwsh.exe' : 'bash',
    [],
    environment: {...Platform.environment, 'codefu': '1234'},
    raw: true,
  );

  pty.resize(120, 40);

  if (Platform.isWindows) {
    pty.write('dir\r\n');
  } else {
    pty.write('ls -la\n');
  }
  if (Platform.isWindows) {
    pty.write('echo \$env:codefu\r\n');
  } else {
    pty.write('echo \$codefu\n');
  }

  pty.out.listen((data) {
    stdout.write(data);
  });

  await Future.delayed(const Duration(seconds: 1));
  pty.kill();

  print(await pty.exitCode);
}
1
likes
160
points
1.8k
downloads

Documentation

API reference

Publisher

verified publishermcdole.org

Weekly Downloads

Pty2 for Dart and Flutter. Provides the ability to create processes with pseudo terminal file descriptors.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

ffi, lints, win32

More

Packages that depend on pty2