Skip to content

Instantly share code, notes, and snippets.

@PrestonKnopp
Created October 23, 2019 23:40
Show Gist options
  • Save PrestonKnopp/9bd59cadfe8a2c95d914df3ee8c70fa1 to your computer and use it in GitHub Desktop.
Save PrestonKnopp/9bd59cadfe8a2c95d914df3ee8c70fa1 to your computer and use it in GitHub Desktop.
Get piped in stdin if available
import 'dart:io' show stdin;
import 'dart:convert' show utf8;
main() async {
try {
String input = await stdin.timeout(Duration.zero).transform(utf8.decoder).first;
print(input);
} on TimeoutException {
print('No input was piped into stdin');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment