readAsString method

Future<String> readAsString()

Reads the File and returns the content as a string.

Implementation

Future<String> readAsString() async {
  final Completer<String> completer = Completer<String>();
  final FileReader reader = FileReader();

  void changeEventListener(Event e) async {
    final String text = (reader.result as JSString).toDart;
    completer.complete(text);
  }

  reader.addEventListener('load', changeEventListener.toJS);
  reader.readAsText(this);

  return completer.future;
}