Questions tagged [dart2js]

The Dart to JavaScript compiler that reads a Dart file and translates it to JavaScript.

The Dart to JavaScript compiler that reads a Draft file and translates it to JavaScript. It generates JavaScript source code from the Draft files. The name of the tool used to compile the code is draft2js. Dart Editor uses dart2js behind the scenes whenever Dart Editor compiles to JavaScript. It produces a file that contains the JavaScript equivalent of the Dart code. It also produces a source map, which can help to debug the JavaScript version of the app more easily.

196 questions
1
vote
1 answer

How to return values from main function in js code created by dart2js

I have dart code that returns a string when it is ran main(){ print("hello"); return "hello"; } Now i need to call this from js so i used dart2js to convert it to js. How i call it from a node.js application: var sudokuLib =…
Joel
  • 239
  • 3
  • 21
1
vote
1 answer

How to access window.navigator.serial in flutter web

On some browsers there exists the the property serial on the window.navigator object. I can see it on chrome but not on safari. How can I access that object via dart in flutter web? dart:html doesn't seem to include it. Is there a way to manually…
xerotolerant
  • 1,955
  • 4
  • 21
  • 39
1
vote
0 answers

How to cast/convert a browser FormData object to a Dart object, in Flutter Web?

Basically I have a FormData object on the Javascript side in Flutter Web. I need to send this object to Dart in order to make a http POST request, having the object's fields (including some eventual Blob/File field, as well) as the payload. The way…
1
vote
2 answers

Does dartpad not support I/O?

Recently I was trying out some code snippets from "Dart For Absolute Beginners" on DartPad. Specifically: import 'dart:math'; import 'dart:io'; void main() { int guess; Random rand = new Random(); //create a random number generator int…
Jay
  • 110
  • 10
1
vote
1 answer

Error during http request in Firebase function generated by dart2js: ReferenceError: XMLHttpRequest is not defined

I am using dart2js to create firebase functions. Within such a function I have to invoke a http request for some web apis (in this example a simple web-site request to www.google.com :-)), but get "ReferenceError: XMLHttpRequest is not defined".…
1
vote
0 answers

How to use Dart classes in Javascript

I know a lot changed since Using Dart classes from JavaScript It is now possible to use dart classes inside Javascript? I have some classes that call some APIs that I want to use in my Javascript app for the web.
Ionel Lupu
  • 2,695
  • 6
  • 29
  • 53
1
vote
1 answer

Check if element is child of another in Dart

I need to check if a clicked element is child of another, using jQuery I would do: $(event.target).parents('#foo').length === 1 but with dart I have no clue. void main(){ (querySelector('body') as…
Mattia
  • 5,909
  • 3
  • 26
  • 41
1
vote
0 answers

dart2js: Clean HTML whitespaces at compilation

I'm creating an element with the dart:html lib. I'd like the indentation to be pretty on the Dart side, but as a matter of keeping the generated js as compact as possible, I'd like the compiler to clean up the string removing unnecessary…
maphe
  • 1,904
  • 3
  • 20
  • 26
1
vote
0 answers

Mouse event for download working with dartdevc, but not dart2js

I am trying to use code modeled after https://stackoverflow.com/a/29702251/9885144 to do an HttpRequest, generate a download link from the returned blob, then automatically download it (all after clicking a button). Here is the function that runs…
1
vote
0 answers

Dart/WebStorm Issue

Forgive me for being a novice. I am a self taught coder which I know is tough because I didn't learn the fundamentals first etc... With that said, I am 6 months into a web app and had to move to a new machine. On the new machine I am having a weird…
user2649292
1
vote
1 answer

Does compiled AngularDart pollutes global scope or overrides Standard objects of the browser?

I'm looking for a framework that will allow me to write a SPA and a embeddable library. I would love to have a way to share component between both. So I'm looking for a solution that has relatively small amount of potential conflicts with other…
como eStas
  • 43
  • 3
1
vote
1 answer

Can we transpile dart code to multiple JS files?

Let's say that a developer has created a general-purpose Dart library, aimed at the client, that contains a large number of class and functionality definitions, of which only a small subset is ever expected to be used in a single web page. As a…
Richard Ambler
  • 4,816
  • 2
  • 21
  • 38
1
vote
1 answer

Dart2JS Pub Build Fails to Traverse Project Folders Correctly

I'm working on a long-term project for some time now. After moving some folders around, correctly refactoring different parts of the code, Webstorm's Dart analyser is showing NO errors, but running either pub serve or pub build fails. Pub or Dart2JS…
1
vote
1 answer

Dart, conditional loading of Angular 2 packages/modules

Can output of dart2js (and angular2) be split into multiple packages and conditionally loaded during app runtime? Similar to how RequireJS can do conditional loading of app parts/packages. Example:
Peter
  • 904
  • 1
  • 13
  • 26
1
vote
1 answer

How can I generate code to export functions for node in Dart?

(I failed at getting this working in dart2js so I'm trying in dart dev compiler; but I'd happily take an answer for dart2j!). If I have test.dart: void activate() { print("activating..."); } and run dartdevc --modules node -o test.js test.dart…
Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275