Dart 2 Migration Guide for Web Apps
This page will guide you through migrating your Dart 1.x web app to Dart 2. These changes are necessary because of the following:
- Chrome replaces Dartium and content-shell.
- A new build system replaces
pub serve, pub transformers.
- Dart 2 language and library changes.
The development environment for web apps is different in Dart 2 from Dart 1.x. Here are the highlights:
|Dart 1.x||Dart 2|
|Dartium, content shell||Chrome and dartdevc|
|pub transformers||build package transformers. See: Transforming code|
To migrate to Dart 2, you’ll need to edit your web app’s project files:
pubspec.yaml, see details below.
- HTML files with
<script src="foo.dart"...>elements, such as
web/index.html. See details below.
- Dart code, due to changes in the Dart language and libraries.
For complete examples of migrated apps, compare the
of any one of the angular-examples apps, such as these:
Make these changes to your
- Add new
build_test: ^0.10.2, if you are running tests
- Upgrade to
testversion 0.12.30 or later; it runs Chrome tests headless by default.
- Drop all
For example, here is a diff of angular-examples/quickstart/pubspec.yaml with these changes applied.
HTML with script elements
The most common example of a file with
<script> elements is
You’ll need to make these changes:
<script defer src="packages/browser/dart.js"></script>
<script defer src="foo.dart" type="application/dart"></script>
<script defer src="foo.dart.js"></script>
Here is a diff of angular-examples/quickstart/web/index.html with these changes applied.