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
2
votes
1 answer

Dart code not working after compiled to JS

So.. there's something weird happening to me. My code in Dartium was working perfectly until I compiled it o JS. Now only the JS version of it works.. If I compile to JS then I run the program it works. But the Dart Code by itself no long works…
Marcus Gabilheri
  • 1,259
  • 1
  • 14
  • 26
2
votes
1 answer

How to achieve precompiler directive like functionality

I'm developing an angular app, and it's recommended to use generated code for a lot of things running in production, namely template caches, expression caches, and a static DI injector. There's currently no nice way to switch between different…
w.brian
  • 16,296
  • 14
  • 69
  • 118
2
votes
2 answers

After compiling from Dart to Javascript, document.querySelector can't find

I'm getting null when trying to find element with querySelector() on document object after compiling to javascript. Here's the Dart code: void main() { print(document.querySelector('body')); // => null } This also produces a range…
orion3
  • 9,797
  • 14
  • 67
  • 93
2
votes
1 answer

how to read stdin and write to stdout with dart2js

according to this answer the dart:io libraries are only for the server/command-line, so they can't be compiled with dart2js. is it possible to read from stdin and write to stdout with dart2js e.g: $ java -jar ../../Downloads/rhino1_7R4/js.jar…
Rusty Rob
  • 16,489
  • 8
  • 100
  • 116
2
votes
1 answer

dart2js: Uncaught TypeError: Object # has no method 'split'

I'm working on simple online building planner tool, which uses svg element (dart:svg library) as editor canvas. Development build works perfect in native Dartium VM, but after running dart2js I'm getting next error in any browser: Uncaught…
Freight5
  • 35
  • 3
2
votes
2 answers

dart vm works but dart2js fails

I am doing polymer dart. Everything works fine with dart vm but when I try to deploy it, it fails (compilation was okay.) When I run the built js version. It gave me the error Uncaught TypeError: Cannot call method 'shL' of null I tried to trace…
yi chen
  • 241
  • 4
  • 11
2
votes
1 answer

Dart compiled to JS but object notation is not working

I have created a Dart app and grabs weather information from some weather API source. Just out of my curiosity, I want to test if I can encapsulate the weather information in an object and then render the object's properties in the Polymer…
TaylorR
  • 3,746
  • 5
  • 25
  • 42
2
votes
1 answer

Compiling dart to separate js files

I am trying angular.dart. When I compile dart to js it generates a single file which is containing my dart code and whole of angular and may be other libraries also. The problem is file size becomes too large ( 1.5L+ lines ). This also means…
2
votes
1 answer

Adding children to SelectElement in Dart

I am creating a (very large) select element that needs to be added in several places on a single page. Instead of recreating it for every instance I am making a single prototype and then doing a deep clone on it for each instance and adding some new…
2
votes
1 answer

How to deploy a dart app as a html file or as a folder containing an html file that someone can run offline

Can I can distribute a dart application to a client as a folder or html file so it can be run by clicking the html file to run the app offline? I can run my dart app that resides on my local 127.0.0.1 but not by clicking the html file in the web…
Dittimon
  • 986
  • 2
  • 14
  • 28
2
votes
1 answer

Dart2js : Is it possible to start Root Isolate from Javascript?

I have an application compiled in dart2js (Dart SDK version 0.6.13.0_r25630) and I'd like to load it with RequireJS everytime I need. First of all, thanks God for wrapper function in compiled javascript, but in my case is not enough :( I use…
marcaia
  • 48
  • 6
2
votes
2 answers

How to generate javascript with Dart editor

When I select Tools > Generate Javascript in Dart editor, I get an error message saying that I need to select a Dart library. I want to convert the entire project into javascript. I can't figure out how to do that.
user2267395
  • 149
  • 1
  • 1
  • 5
1
vote
1 answer

How can I convert a Dart Future to a Javascript Promise?

The dart code I compile is: import 'dart:js'; import 'package:dio/dio.dart'; final Dio _dio = Dio(); class LoginResponse extends GenericResponse { String? accessToken; String? refreshToken; LoginResponse(statusCode, this.accessToken,…
Vassily
  • 5,263
  • 4
  • 33
  • 63
1
vote
1 answer

What's the most efficient way to make a single-item Iterable in Dart?

In Dart, single-item iterables can be created in various ways. ['item']; // A single-item list Iterable.generate(1, (_) => 'item'); // A single-item generated Iterable How do these methods compare in terms of speed and memory usage, during both…
hacker1024
  • 3,186
  • 1
  • 11
  • 31
1
vote
0 answers

The compiler dart2js crashed: Null check operator used on a null value

Hello I faced some issue when I built my Flutter app for web NOTE THAT MY APP RUNS WELL IN DEBUG MODE Module dart2js My OS: macOS Monterey - 12.3.1 (21E258) Dart Sdk build number 2.15.1 The full stack trace The compiler crashed: Null check operator…