close method

Future<void> close()

Puts the terminal back the way it was and stops reading input.

A readLine call still waiting returns null. Safe to call twice.

Implementation

Future<void> close() async {
  if (_closed) return;
  _closed = true;
  _restoreRawMode();
  _completing = false;
  _generation++;
  final Completer<String?>? reading = _reading;
  _reading = null;
  if (reading != null && !reading.isCompleted) reading.complete(null);

  final StreamSubscription<List<int>>? subscription = _subscription;
  _subscription = null;
  await subscription?.cancel();
}