I'm get this error with a angular 1.0.0 project and I don't know what this means and what should be done. I do not understand the explanation in link https://github.com/angular/di.dart/wiki/Uninitialized-Module.DEFAULT_REFLECTOR-error
My project declare one dependency in a library that declares a dependency in angular. So my project doesn't have a direct dependency in angular and I can't declare transformers in the pubspec.yaml file.
I got the same error when I was using main() async - so removing the async and going back to the conventional Future-base version was the solution.
I filed an issue report: https://github.com/angular/di.dart/issues/221
Angular now use static generated content. The html files for components are processed during pub install or pub serve
The pubspec.yaml file needs something like:
transformers:
- angular:
html_files:
- web/controllers/error_warning_controller.html
- web/controllers/http_interceptor_controller.html
- web/controllers/notify_tray_controller.html
- web/controllers/notify_desktop.html
- web/controllers/panel_controller.html
- web/controllers/window_controller.html
dart_sdk: /usr/local/opt/dart/libexec
Also it not work if you use a library that depends on angular you need a direct dependency for angular transform to work, I work around declaring the dependency twice, one for the library one for the project that use the library.
Related
Background
Trying to use a pure-dart package from a Flutter-project.
The pure-dart package basically is a Database. It reads its own JSON-assets and answers to queries.
The Flutter-project accesses the pure-dart package as a database: PureDart.tellMe("something").
The Flutter-project is not accessing the assets of the pure-dart project directly.
Tried
Inversion-Of-Control seemed interesting, but it does not for work me. The error is always Error while trying to load an asset: Failed to load asset at "assets/BLA.json" (404).
I tried various variations of defining the assets.
How to access asset file in pure dart package?
Question
How to define the assets of the pure-dart package, and where? Do they need to be defined in the Flutter-project and the pure-dart package?
Is there a working example out there demonstrating how to achieve this?
There are a few blog posts and questions on SO regarding this topic, but none actually lead to a working example.
Thanks.
As there seems not plausible way to make a pure-Dart package accessing its JSON-assets, when used consumed by a Flutter project, the alternative is to turn the pure-Dart package into a Flutter project.
The Database-Flutter project needs to access its own assets as follows:
var json = jsonDecode(
await rootBundle.loadString(
'packages/DATABASE_PACKAGE_NAME/assets/asset.json'
)
);
Its pubspec.yaml defines the assets as usual:
dependencies:
flutter:
sdk: flutter
flutter:
assets:
- assets/
The Flutter project consuming the Database-Flutter project simply adds it as a dependency.
I recently stumbled across Dart, and got pretty excited about it because it almost feels like that perfect language I've always been looking for. I work with PHP at my job (Yes, I know, ew gross) as a web developer and was excited to try and build a web app using the language. Figured it couldn't be too hard as that's what Dart was originally made for. Turns out it more difficult than I though, and I can't even get off the ground. I was hoping someone else could help point me in the right direction.
So, I really haven't done any real coding in this project at all. I literally downloaded the Dart SDK, used stagehand to create web-simple project, then I added a bin/server.dart file to the project. The code in that file was pretty much taken straight out of the online documentation for the mojito package:
import 'package:mojito/mojito.dart';
main() {
var app = init();
app.router
..addStaticAssetHandler('/static');
app.start();
}
I added the dependency mojito: "^0.6.6" to the pubspec.yaml file as well of course. That's all I've done though, like I say, I haven't even managed to get off the ground yet.
When I run server.dart I get the following error:
'package:convert/src/percent/encoder.dart': malformed type: line 23 pos 13: cannot resolve class 'ChunkedConverter' from 'PercentEncoder'
I get the exact same error message if I try to build a server with the shelf_rest package instead of the mojito package.
A search of that error message doesn't bring up too much helpful info, though I found one forum where someone recommended adding convert: ^2.0.1 to the dependencies. Apparently there was a change made in that package that causes incompatibility with other packages. I tried that suggestion but it doesn't seem to be resolving the issue.
I'm certain the issue is some sort of dependency issue, I'm probably using a mix of dependencies that I guess just aren't meshing right. If someone could help me figure out what I'm doing wrong it would be much appreciated. I want to learn and start using Dart but obviously I'm not having such great luck with it...
Here's what the pubspec.yaml looks like in case it helps:
environment:
sdk: '>=1.24.0 <2.0.0'
dependencies:
shelf: ^0.6.0
mojito: "^0.6.6"
convert: ^2.0.1
dev_dependencies:
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
- dart_to_js_script_rewriter
The last version of mojito was uploaded in October 2016 and it seems abandoned. Since then, Dart has added Strong mode and begun transitioning to Dart 2. This included significant changes to the type system and updates to SDK libraries.
Additionally, transformers have also been removed - any documentation you find referencing them is out of date. And in this case, the dart2js script rewriter is for client side JavaScript, not servers.
If you're looking for Server libraries, I would recommend just starting with the latest version of Shelf
I'm porting an existing angular2 ts library to Dart.
Everything's working in Dartium but after building the app won't run in Chrome.
I'm getting an "The selector "demo-app" did not match any elements" error.
Not sure how to debug, any help would be appreciated!
Please see https://github.com/laagland/ng2-dart-pagination for the code.
- dart_to_js_script_rewriter
should be the last transformer.
Also add this setting to the Angular transformer
- angular2:
platform_directives: 'package:angular2/common.dart#CORE_DIRECTIVES'
See https://github.com/kwalrath/angular.io/blob/d87fb0995aafe5da1c2be708986d74828b65d55c/public/docs/_examples/forms/dart/pubspec.yaml for an example.
You should try to avoid mirrors in browser applications because it causes code bloat. I didn't chech all your code, but I saw the #MirrorsUsed annotation. If you need reflection, use the reflectable package instead.
So I found this nice port of Chart.js as a polymer component on customelements.io but I'm not able to use them in my polymer.dart project. I copied all the files from the library project into my project and fixed the paths but the elements are not showing up. I get
Uncaught ReferenceError: Polymer is not defined chart-bar.html:27(anonymous function) chart-bar.html:27
(+ same error for the other files from the library proj).
I have no bower.json in my project (but a pubspec.yaml) and I'm wondering if I need one because the library project got one in there?
So what is the right way to get those polymer elements into my project?
There is currently no straight-forward way to use Polymer.js polymer elements in a Polymer.dart project.
You can try to generate Dart wrappers using https://github.com/dart-lang/custom-element-apigen / https://pub.dartlang.org/search?q=custom-element-apigen.
The code generation depends on proper JavaScript codedoc in the JS elements which is often incomplete but I have heard of people who were satisfied by the result (Dart core_elements/paper_elements are generated with this but there is also manual work involved).
I'm trying to put paper elements in my angularDart app, so I have put in my pubspec.yaml the following dependencies:
dependencies:
angular: ">=1.0.0 <2.0.0"
paper_elements: ">=0.5.0 <0.6.0"
And then when I try to pub upgrade I get the following:
Pub: Upgrade Dependencies: Incompatible version constraints on
html5lib:
- angular 1.0.0 depends on version >=0.10.0 =0.11.0 <0.13.0
I'd really like to use the 1.0.0 (at least) version of angular Dart, however I was wondering if there was a way to satisfy both libs' dependencies. (and how does someone get to know what the correct dependencies' versions are)
Note that I tried doing the same with Polymer and facing the same problem (with a different dependency), so a general way of working around this would help, instead of just giving version numbers.
Just use dependency overrides.
dependency_overrides:
html5lib: 0.12.0
There is no way to satisfy both when their constraints have no common set.
It's at your own risk when one of them doesn't work properly with the specified version.