package "dart_to_js_script_rewriter" is not a dependency - dart

I just started learning dart.
first I created an angular2-dart based project from https://angular.io/docs/dart/latest/quickstart.html and it worked properly.
now I want to add auth0-lock dart package from https://pub.dartlang.org/packages/auth0_lock, so I modified pubspec.yaml to the following:
name: go_dart_angular2_zingchart
description: Go Dart Angular2 with ZingChart Started Kit
version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: ^2.0.0-beta.18
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
auth0_lock: ^0.1.0
transformers:
- angular2:
platform_directives:
- 'package:angular2/common.dart#COMMON_DIRECTIVES'
platform_pipes:
- 'package:angular2/common.dart#COMMON_PIPES'
entry_points: client/web/main.dart
- dart_to_js_script_rewriter
and now when I execute pub get I get the following error:
Error on line 15, column 3 of ../../../.pub-cache/hosted/pub.dartlang.org/auth0_lock-0.1.0/pubspec.yaml: Error loading transformer "dart_to_js_script_rewriter": package "dart_to_js_script_rewriter" is not a dependency.
- dart_to_js_script_rewriter
^^^^^^^^^^^^^^^^^^^^^^^^^^
since I'm new to dart and not entirely sure what I'm doing.. I have no idea how to fix this :)
any ideas ?
thanks!

I get the same error when adding auth0_lock: ^0.1.0 to my dependencies and running pub get. The error message says that "dart_to_js_script_rewriter" is not a dependency in the pubspec.yaml of the auth0_lock package. It looks like it's added under dev_dependecies if you look here. Dev dependencies of any dependent packages are ignored. Pub only gets your package’s dev dependencies.
So I think this is a problem in their package.
So, what I did was I went to https://github.com/andresaraujo/auth0_lock.dart and cloned the package, added it into my own project root in a directory called auth0_lock. And then, in my pubspec.yaml i put:
auth0_lock:
path: auth0_lock
After that I can import it using
import 'package:auth0_lock/auth0_lock.dart';

Related

Dart Webdev Dev Compiler not running since upgrade to 2.3.2

Since I have moved from Dart 2.1.0 to 2.3.2 "webdev serve" runs successfully, but when I run the project, it gets a 404 on "main.digests". I updated my dev dependencies of build_runner, build_web_compiler, and webdev to the latest versions, and the issue still occurs.
It still builds in dart2js fine. Even if it is "webdev serve --release" it works.
Here is a copy of my pubspec:
environment:
sdk: '>=2.3.2 <3.0.0'
dependencies:
analyzer: any
intl: any
stagexl: 1.4.0+2
stagexl_particle: ^0.4.0
uuid: ^1.0.3
dependency_overrides:
stagexl:
git: https://github.com/AndrewLugg/StageXL.git
dev_dependencies:
build_runner: ^1.6.1
build_web_compilers: ^2.1.1
webdev: ^2.2.0
and here is my build.yaml
targets:
$default:
builders:
build_web_compilers|entrypoint:
generate_for:
- web/app/**.dart
options:
dart2js_args:
- --fast-startup
- --no-source-maps
- --show-package-warnings
- --trust-primitives
- --trust-type-annotations
- --omit-implicit-checks
Here is a copy of the error:
http://localhost:53322/webdev/src/serve/injected/client.js:2693
GET http://localhost:53322/app/main.digests 404 (Not Found)
Uncaught Instance of 'minified:b0' client.js:367
Any help would be greatly appreciated.
This problem disappeared once we upgraded to Dart SDK 2.5.2, there was no real explanation to why this happened.

The imported library 'package:geolocator/model/position.dart' can't have a part-of directive

In my flutter app I have been using these following plugin permission_handler, geolocator and google_api_availibility.
I could have added this plugin from flutter package from pubspec.yml, however, in my app i am using google_map_flutter plugin which has been using AndroidX support libraries. Due this reason I have added those library locally with some changes to work with AndroidX. So my app structure and pubspecs looks like this.
So in my app pubspecs.yml
dev_dependencies:
flutter_test:
sdk: flutter
permission_handler:
path: my_permission_handler
geolocator:
path: flutter-geolocator
My my_permission_handler's pubspecs.yml
flutter:
plugin:
androidPackage: com.baseflow.permissionhandler
pluginClass: PermissionHandlerPlugin
My api_availibility's pubspec.yml
flutter:
plugin:
androidPackage: com.baseflow.googleapiavailability
pluginClass: GoogleApiAvailabilityPlugin
My geolocator's pubspec.yml
dependencies:
meta: "^1.0.5"
flutter:
sdk: flutter
permission_handler:
path: ../my_permission_handler
google_api_availability:
path: ../flutter-google-api-availability
Now when in one of the project's classes I tried to import a model class from geolocator like this
but it shows this error The imported library 'package:geolocator/model/position.dart' can't have a part-of directive
I have no idea what I'm doing wrong here, please help me.
First of let's look into the code for package:geolocator/modles/position.dart
It says part of geolocator; at the very beginning of the file meaning this class is a part of the plugin which is exposed in the file package:geolocator/ like this part 'models/position.dart';. So here in your client code you don't need to import the class Position this way.
if you modify your import statement this way the error will be gone
import 'package:geolocator/geolocator.dart';
I hope it helps.

'pub get' gives an error for Angular2 package

I have a 'pubspec.yaml' with below content:
# #docregion
name: angular2_tour_of_heroes
version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
platform_directives:
- package:angular2/common.dart#COMMON_DIRECTIVES
platform_pipes:
- package:angular2/common.dart#COMMON_PIPES
entry_points: web/main.dart
When I run 'pub get' in command line, get below error:
Resolving dependencies...
Got dependencies!
Precompiling dependencies...
Loading source assets...
Loading angular2/transform/codegen, dart_to_js_script_rewriter, observe and smokLoading angular2/transform/codegen, dart_to_js_script_rewriter, observe and smokLoading angular2/transform/codegen, dart_to_js_script_rewriter, observe and smoke/src/default_transformer transformers...
Transformer library "package:angular2/transform/codegen.dart" not found.
How do I fix it?
Create bug report: https://github.com/dart-lang/pub/issues/1406
I had the same issue and spent a ton of time trying to fix it. My root cause was after I migrated to a new computer. My hosts file did not migrate. Once I added 127.0.0.1 localhost to my hosts file it started working.

How to configure existing project to use polymer dart 1.0.0-rc.2?

I created new polymer dart project with dependences:
dependencies:
polymer: ^1.0.0-rc.2
web_components: ^0.12.0
polymer_elements: ^1.0.0-rc.1
browser: ^0.10.0
reflectable: ^0.3.1
dependency_overrides:
polymer_interop:
git:
ref: 0.2.0-rc1
url: https://github.com/dart-lang/polymer_interop.git
and everything worked fine (I can create new dom-module and use polymer elements). But then I tried to use exactly the same dependency configuration in existing project and when I run pub get I get:
Package reflectable has no versions that match >=0.3.1 <0.4.0 derived from:
- fbnn depends on version ^0.3.1
- polymer 1.0.0-rc.2 depends on version ^0.3.1
- polymer_elements 1.0.0-rc.1 depends on version ^0.3.1
I also try to do pub cache repair but it didn't help. Any ideas what might be wrong?

Pub get 'Connection closed before full header was received' Angular + Polymer

I am trying to get packages from the PUB with the following:
name: 'ch_padart'
version: 0.0.1
dependencies:
angular: "1.1.0"
angular_node_bind: any
polymer: ">=0.15.5+2 <0.16.0"
core_elements: ">=0.6.0+4 <0.7.0"
paper_elements: ">=0.6.1 <0.7.0"
web_components: ">=0.9.0 <0.11.0"
browser: ">=0.10.0+2 <0.11.0"
dev_dependencies:
unittest: ">=0.11.0+5 <0.12.0"
mock: ">=0.11.0+2 <0.12.0"
transformers:
- angular:
html_files:
- web/index.html
- polymer:
entry_points: web/index.html
lint: false
but the end result is always 'Connection closed before full header was received'
If you remove angular OR polymer (and elements) and then run pub get, there is no issue and all download and runs fine. No other warnings are displayed and --verbose yields nothing helpful that I can see.
When you run pub get -v from command line you will see that pub is working quite hard but can't find a compatible set of dependencies. There was a similar issue recently that the I guess the collection package was required in different dependencies with non-overlapping version constraints.
This is quite common when using Angular with Polymer.
You might need to investigate the dependencies manually to find the cause.
Maybe you get some feedback from pub get when you remove all dependency constraints and then start adding them again one by one.
the pubviz packages helps to resolve this kind of issue as well: https://pub.dartlang.org/packages/pubviz

Resources