Question

I wrote a Dart web app that compiles to Javascript (dart2js), which I package in an APK (PhoneGap) and run as an Android app. I want my app to backup and restore its data from the local file system.

W3C has a File API standard for file IO within a web browser: http://www.w3.org/TR/FileAPI/#introduction.

A popular HTML5 learning website has an article showing how to use the W3C File API: http://www.html5rocks.com/en/tutorials/file/dndfiles/

I tried to use Dart's dart:io library to write to a file from a web page, but got this error:

Failed to load a file dart:io
 Failed to load resource
   dart:io

I'm not sure what caused this error. Maybe dart:io doesn't run in a browser. Maybe dart:io has an undocumented pubspec dependency (I didn't see any dart:io examples that declare its dependencies.)

If you know how to read/write files in a web browser using Dart, please explain how to do it.

Thanks

Was it helpful?

Solution

dart:io is a Server library, you have to use File from dart:html.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top