fileSystem.chooseEntry from package:chrome/app.dart generates runtime error - dart

Has anyone successfully used any fileSystem calls in package:chrome/app.dart? (This is the Chrome API package for Google Dart.)
Here's my code:
import 'package:chrome/app.dart';
void main() {
fileSystem.chooseEntry();
}
Here's my pubspec.yaml file:
name: ChooseEntry
description: A sample chrome packaged application
dependencies:
browser: any
chrome: any
meta: any
The other files were generated automatically by the Dart Editor and remain untouched by me.
The error I get from Dartium is:
Breaking on exception: 'package:chrome/src/common.dart': malformed type: line 72 pos 29: type 'js.Callback' is not loaded
When I compile to JS and run in Dartium or Chrome, I get this error:
Uncaught RuntimeError: Error: Cannot resolve 'Callback'.
So, my question is whether anyone has successfully used the chooseEntry API, or any API in fileSystem and, if so, what about what I did needs to be fixed. My guess is that I'm missing a package, but I can't identify what it might be.
I did add package "js" to pubspec.yaml, with no effect. I also tried making copies of all the packages, in case Dartium or Chrome didn't handle the symlinks correctly, and that didn't help either. (I doubt that that's the problem, as it found the code for fileSystem.chooseEntry just fine.)
I'm using:
Dart Editor version 1.0.0_r30798 (STABLE)
Dart SDK version 1.0.0.10_r30798

The chrome package appears not to be maintained anymore, consider using chrome_gen instead by replacing chrome with chrome_gen in pubspec.yaml and by editing the import statement like this:
import 'package:chrome_gen/chrome_app.dart';
main() {
fileSystem.chooseEntry();
}
The difference between these two packages is that wrappers are hand-written in chrome and autogenerated in chrome_gen from the json and idl files from Chrome.
Links:
Pub Package: chrome_gen
Mailing List: What is the difference between chrome and chrome_gen ?

Related

Angular Dart Import Error With Tracing.dart

I am using Angular Dart for a project. In my pubspec.yaml I have
dependencies:
browser: any
angular: "^1.1.2+2"
shadow_dom: any
json_object: any
bootjack: any
crypto: any
xml: "^2.3.2"
transformers:
- angular
for my dependencies. When I run my program in Dartium I get the error
The requested built-in library is not available on Dartium.'package:angular/tracing.dart': error: line 9 pos 1: library handler failed
import "dart:developer";
^: package:angular/tracing.dart
I never reference or use anything out of the tracing.dart so I'm not sure why this is causing an error.
The tracing package is directly using dart:profiler, which was deprecated and now removed. You can now use dart:developer instead, both libraries are compatible.
I would suggest to fork the package, replace dart:profiler with dart:developer (no other changes are required) and send a pull request. I already forked and fixed the package some time ago here, but I think the original package is inactive so I didn't created an PR. You can use my fork by adding this to your pubspec.yaml:
dependency_overrides:
tracing:
git: https://github.com/Fox32/tracing.dart.git
dart:profiler was recently renamed to dart:developer. One of your dependencies probably use an analyzer version that doesn't fit to your Dart version.
See also https://github.com/dart-lang/pub/issues/1345

Dart2JS Cannot Find Import Packages WebStorm

I am using the WebStorm 8 IDE to build a dart web app. I have the following directory structure:
root
web
main.dart
lib
packages
browser
intl
intl.dart
pubspec.lock
pubspec.yaml
In main.dart I have the following import statment: import "package:intl/intl.dart";
However when I try and compile main.dart to javascript I get the following error:
dart2js
Error occurred:
/Path/To/Project/root/web/main.dart:2:8:
Error: Can't read 'package:intl/intl.dart' (Error reading '/Path/To/Project/root/web/packages/intl/intl.dart' (OS Error: No such file or directory, errno = 2)).
import "package:../packages/intl/intl.dart";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Compilation failed.
So it seems that dart2js looks in the current directory of the dart file to be converted for the packages, which is incorrect.
I tried changing my import statement to import "package:../packages/intl/intl.dart"; but I got the same error.
Does anyone have any ideas?
UPDATE:
I can use pub build to build my project and produce a main.dart.js. Not sure what is different when I call build, perhaps something is wrong with WebStorm?
dart2js is not a recommended workflow and can be buggy in WebStorm 8. It is completely removed from the context menu in the upcoming WebStorm 9. Use 'pub build'.
I can't see anything wrong. I think this is one of the cases where only
pub cache repair
can help.

Dart web application can not import local package

I have developed a simple library (called picasawebalbums) that I wish to import in another web application.
I have added the the following to pubspect.yaml
picasawebalbums:
path: C:\Users\hangs_000\Documents\GitHub\PicasaWebAlbums
But the package does not appear under the 'packages' directory and of course my dart code cannot import any of the classes.
I feel that I have missed out a step somewhere.
Try pub get --verbose or pub upgrade --verbose from command line in your application directory and look at the output. You can try without --verbose first. This prints much less but may offer a hint anywhere.

Failed to load package in Dart

When I try to import a package with the syntax import 'package:markdown/markdown.dart';, I get no error in Dart Editor but when I run the dart application, the debugger shows me the message:
An error occurred loading file: package:markdown/markdown.dart
Failed to load resource
chrome-extension://gfjabgeipkcfopofkhjimepepnomcidk/dart/packages/markdown/markdown.dart
But when I write the whole path (import "../../packages/markdown/markdown.dart";) everything works fine. I cannot understand why the syntax package: doesn't work in my code though it works in Dart Editor's own examples.
You can see the Chrome app architecture below (I'm loading a package from translator.dart):
You should have the package added as a dependency in pubspec.yaml (which I assume you do).
Also try running following:
delete packages folder
delete pubspec.lock
run pub get to fetch the
dependencies again.
I think in your md_to_html folder you need a link to the 'packages' directory for the shortform to work. I seem to remember this happening when the workspace is built but I'm not sure now which command triggers it, have a look at the current pub docs.

Dart pub is not downloading dependencies

I had moved my Dart Project to another folder, with the same folder structure, however, now, I'm receiving the following message:
Running pub install ...
Pub install failed, [1] Resolving dependencies...
Could not find package "dartflash 0.6.3" at http://pub.dartlang.org.
Here is my pubspec.yaml:
name: Chronium
description: A framework for doing Chrono like games.
dependencies:
dartflash: 0.6.3
And pubspec.lock:
{"packages":{"dartflash":{"version":"0.6.3","source":"hosted","description":"dartflash"}}}
And the file structure:
The website (http://pub.dartlang.org/) is accessible from the browser.
I'm on dart (Dart Editor version 0.2.9_r16323). Do someone knows what is happening?
According to Seth Ladd post, this should be fixed now :
If you were having troubles with pub.dartlang.org, we're happy to report that we've fixed the issue. Many apologies for the temporary downtime. Looks like it was an issue with the server pointing to the wrong data store. Thanks for all the reports, the pub is open again!

Resources