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
6
votes
4 answers

how to deploy dart web app with dart packages?

Consider the following dart web app: import "dart:html"; // assume this is a custom library hosted somewhere on github, i.e. // there is a pubspec.yaml entry // // dependencies: // my_hello: // git:…
gubaer
  • 236
  • 2
  • 11
6
votes
3 answers

Using js-interop how can I convert javascript Array and Object to native dart Map.

Is it possible to convert a javascript object or array back to native dart Map and/or List? I'm trying to get a manifest file returned from javascript as Object and want to convert it to a Dart Map object.
adam-singer
  • 4,489
  • 4
  • 21
  • 25
5
votes
3 answers

Is it possible to only convert a dart function to javascript

I am currently using the following package where the readme illustrates the following final bool loaded = await JsIsolatedWorker().importScripts(['test.js']); I am using the isolate worker package so my code can work on web and outside of web. I…
anonymous-dev
  • 2,897
  • 9
  • 48
  • 112
5
votes
4 answers

Flutter web debug is working but build web shows a blank page

flutter doctor result [√] Flutter (Channel dev, 1.21.0-1.0.pre, on Microsoft Windows [Version 10.0.19041.388], locale en-US) [√] Android toolchain - develop for Android devices (Android SDK version 29.0.3) [√] Chrome - develop for the web [√]…
sidrao2006
  • 1,228
  • 2
  • 10
  • 32
5
votes
0 answers

Dart2JS Cannot get async code to run when converted from Dart to Javascript

main() async { print('Hello World'); await getAsyncString().then((hello) => print(hello)); } Future getAsyncString() async { return 'Hello Async World'; } This is my code example, index.dart. It is in my web folder. I run webdev…
John Franke
  • 1,444
  • 19
  • 23
5
votes
1 answer

Preserving methods during dart2js minification and tree-shaking

I have a few files that I have written in dart that I want to compile to javascript and include in a few html files that are running in my Android application. The files consist of a main method, then there is an api layer with 3 functions that…
spierce7
  • 14,797
  • 13
  • 65
  • 106
5
votes
1 answer

how to enable --enable-experimental-mirrors in dart build?

My build of my projects are failing because they rely on mirrors and dart build out put tells me to use --enable-experimental-mirrors to try to use mirrors in dart2js code as it is. so if I run pub build --enable-experimental-mirrors all I get is…
Daniel Robinson
  • 13,806
  • 18
  • 64
  • 112
5
votes
2 answers

How to exclude debug code

Let's say I have simple logger: void main() { var logger = new MyLogger(); logger.log("hello Dart"); } I want this code to run in the dev mode (VM checked mode) but i don't want it in my production code. And i want it to be "tree shaked" away…
JAre
  • 4,666
  • 3
  • 27
  • 45
4
votes
0 answers

How to perform symmetric key encryption on a flutter web project? (dart2js)

Currently flutter web encryption/decryption fails due to unimplemented datatype. "Unsupported operation: Uint64 accessor not supported by dart2js." I want to run the following code from the encrypt flutter package in my flutter web app. import…
jockerThe00
  • 136
  • 1
  • 5
4
votes
1 answer

Dart2js numeric types: determining if a value is an int or a double

I'm trying to determine if a dynamic parameter to a function is really an int or a double and I'm finding surprising behavior (at least to me). Can anyone explain this output (produced on dartpad)? foo(value) { print("$value is int: ${value is…
Brian Neal
  • 31,821
  • 7
  • 55
  • 59
4
votes
0 answers

Dart generated code produces error

Dart 1.20.1 Firefox 49 running on Ubuntu I've got a Dart web app. When I run the generated JS in Firefox I get this error: H.createRuntimeType is not a function The line in question is: C.Type_KeyboardEvent_EaM =…
Alan Humphrey
  • 553
  • 2
  • 11
4
votes
1 answer

How do I set the dart2js --minify option from the command line when executing `pub build`?

For my release process I need several different "modes." However, if I use the --mode option for pub build and set it to any value other than release, it forces un-minified javascript. I know I can configure the dart2js transformer in my…
4
votes
2 answers

Questions on using dart without dart editor

I'm trying to get dart working. As editor I want to use emacs dart-mode. I've got 2 questions concerning using dart without the dart editor: 1) Do I manually need to call dart2js or does the in html included script dart.js do that for me? Where can…
elfeck
  • 385
  • 1
  • 8
4
votes
1 answer

Multiple JavaScript files in Dart?

I ask myself if it is possible to split up a single dart.js into multiple files. I just seek a possibility to convert several independent used JavaScript components in something that is as reusable but yet independently used Dart equivalents.
Martin Kersten
  • 5,127
  • 8
  • 46
  • 77
4
votes
1 answer

How to deploy a Dart Polymer app to Javascript using dart2js

I got a problem while deploying Dart code using Polymer to Javascript. I've created a polymer application with DartEditor and made a simple example. This example works in Dartium but when I try to build it as a Polymer App (in Javascript) and launch…
1
2
3
13 14