How can I create an InputStream from a String in a Dart?

StringInputStream looked like the correct name, but instead of making InputStream from String, it wraps the existing InputStream to read strings from it.

I tried to find the InputStream base class for the extension, and eventually found stream_utils.dart, which I had to copy to my project in order to use.

Will there be ways to create InputStreams and OutputStreams for strings, byte arrays, etc.

+4
source share
1 answer

Here's how you can do it:

import 'dart:io'; main() { var input = "hello from dart"; var inputStream = new ListInputStream(); inputStream.onData = () { print(new String.fromCharCodes(inputStream.read())); }; inputStream.write(input.charCodes()); } 
+5
source

All Articles