Created
August 20, 2020 13:05
-
-
Save apgapg/cfa86eed70c5c7a30341fea1894729aa to your computer and use it in GitHub Desktop.
Read file as Stream in dart
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
void readFileStream() { | |
Stream<List<int>> stream = new File('./assets/user.json').openRead(); | |
StringBuffer buffer = new StringBuffer(); | |
stream | |
.transform(utf8.decoder) | |
.listen((data) { | |
buffer.write(data); | |
}, | |
onDone: () => print(buffer.toString()), | |
onError: (e) => print(e)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment