Skip to content

Instantly share code, notes, and snippets.

@apgapg
Created August 20, 2020 13:05
Show Gist options
  • Save apgapg/cfa86eed70c5c7a30341fea1894729aa to your computer and use it in GitHub Desktop.
Save apgapg/cfa86eed70c5c7a30341fea1894729aa to your computer and use it in GitHub Desktop.
Read file as Stream in dart
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