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 it, the app fails.

How am I supposed to convert a Dart Polymer app to Javascript ?

Here’s the example code I made that fails :

example.html :

<!DOCTYPE html>
    <meta charset="utf-8">

    <link rel="import" href="example-polymer.html">
    <script type="application/dart">export 'package:polymer/init.dart';</script>
    <script src="packages/browser/dart.js"></script>
      <div is="example-polymer"></div>


<polymer-element name="example-polymer" extends="div">
      <input on-change="{{ change }}"/><br>
      <span>Text : {{ text }}</span>
  <script type="application/dart" src="example-polymer.dart"></script>


import 'package:polymer/polymer.dart';
import 'dart:html';

class ExampleBolymer extends DivElement with Polymer, Observable {
  @published String text = "" ;

  ExampleBolymer.created() : super.created() {

  void change(Event e, var detail , InputElement target) {
    text = target.value;



- polymer:
    - web/example.html

to your pubspec.yaml
and call

pub build

Your files should be in the web directory of your package.

Answered By – Günter Zöchbauer

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *