简体   繁体   中英

Using 'dart:io' in dartium ? Any work arounds?

I am new to dart and I am trying to read data from a file and use the contents to draw something canvas. In doing so I am running into 'The built-in library 'dart:io' is not available on Dartium ' issue.

I understand Dart has limitations as Javascript in that code that is running in a browser cannot natively access the File System of the running client.

At the same time are there any tips on how to read a file and also use the contents to write it to canvas?

Thanks in advance.

What kind of application are you trying to build?
If it runs in the browser the files are usually on the server.
If it is a normal web page you can't access user files. There is a sandboxed space accessible to be used by by the code of a webpage.
If you build something like a Chrome app you have less limitations.

You definitely can't import 'dart:io' when the could should run in the browser.
The APIs available in the browser can be found in 'dart:html'.

If you want to build a Chrome app this package provides access to the extended API http://pub.dartlang.org/packages/chrome

I fixed my problem by prompting the user to choose the file. Similar approach as in https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications but using DART.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM