Migrating to ngx_*
The original AngularDart packages (ngdart, ngforms,
ngrouter, ngtest) stopped receiving updates and their last
releases stayed as -dev pre-releases. The
insinfo/angular fork
republished the exact same code as stable versions under the ngx_* family.
From ngdart 8.0.0-dev to ngx_dart 8.0.0
The public API is identical — only the package names changed. Migrating an app is a mechanical find & replace:
1. Update pubspec.yaml:
# Before # After
dependencies: dependencies:
ngdart: 8.0.0-dev.4 ngx_dart: ^8.0.0
ngforms: ^5.0.0-dev.3 ngx_forms: ^5.0.0
ngrouter: ^4.0.0-dev.3 ngx_router: ^4.0.0
dev_dependencies: dev_dependencies:
ngtest: ^5.0.0-dev.3 ngx_test: ^5.0.0
2. Update the imports in your Dart code (project-wide find & replace):
package:ngdart/ -> package:ngx_dart/
package:ngforms/ngforms.dart -> package:ngx_forms/ngx_forms.dart
package:ngrouter/ngrouter.dart -> package:ngx_router/ngx_router.dart
package:ngtest/angular_test.dart -> package:ngx_test/angular_test.dart
3. Rebuild:
dart run build_runner build --delete-conflicting-outputs
Preparing for 9.x: package:web
The next generation (ngx_dart 9.0.0-dev.*, developed on the
master branch)
replaces the deprecated dart:html / package:js stack with
package:web and
dart:js_interop — the same move the Dart team made for the whole ecosystem.
It unlocks WebAssembly (dart2wasm) support and keeps the framework aligned with
the browser APIs of the Web IDL.
Your templates and components do not change, but application code that touches the DOM directly will need the standard Dart migration. The checklist, condensed from the official migration guide:
- Swap the import:
import 'dart:html';→import 'package:web/web.dart';and rundart pub add web. - Renames: package:web uses the original IDL names
(
HtmlElement→HTMLElement,appendChildisappend, ...). Rundart fix --dry-runto apply most renames automatically. ElementvsHTMLElement:querySelectorreturnsElement; downcast withas HTMLElementwhen you need.styleand friends.- Lists:
querySelectorAll/childrenno longer implementList; iterate with the item()/length pair or the package:web helpers. - Type tests:
obj is InputElement→obj.isA<HTMLInputElement>()(Dart 3.4+). - Callbacks: listeners passed to raw DOM APIs need
.toJS(addEventListener('click', callback.toJS)). Stream-basedonClick.listen(...)keeps working via the helpers. - Conditional imports: replace
dart.library.htmlwithdart.library.js_interop. - Nullability: some package:web APIs are stricter than dart:html — e.g.
style.setProperty()takes a non-nullableString(use''to remove a property, which is whatnullused to do).