Created
October 23, 2019 23:40
-
-
Save PrestonKnopp/9bd59cadfe8a2c95d914df3ee8c70fa1 to your computer and use it in GitHub Desktop.
Get piped in stdin if available
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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