I have a problem with transpiling Angular Dart application to javascript.
I got following error messages:
*Loading source assets...
Loading dart_to_js_script_rewriter transformers...
Building testapp...
Building dartdevc modules...
Unable to find module for angular|lib/src/bootstrap/modules.template.dart
Unable to find module for angular|lib/src/bootstrap/modules.template.dart
Build failed.*
Some highlights:
Application works fine with build_runner
I use dart SDK 2.0.0-dev.32.0
I tested and get same results on Win10 and Linux Ubuntu 17
I tested with dartdevc with and without
Below you can see my pubspec.yaml It could be there is an issue what I can not see.
name: testapp
description: A web app that uses AngularDart Components
version: 0.0.1
environment:
sdk: '>=2.0.0-dev.1.2 <2.0.0'
dependencies:
angular: "5.0.0-alpha+6"
angular_components: "0.9.0-alpha+6"
http: "^0.11.3+16"
stream_transform: "^0.0.10"
angular_router: "2.0.0-alpha+6"
js: "^0.6.1"
intl_translation: "^0.16.1"
intl: "^0.15.2"
dependency_overrides:
analyzer: ^0.31.0-alpha.1
dev_dependencies:
webdriver: "^2.0.0-beta"
browser: "^0.10.0+2"
dart_to_js_script_rewriter: "^1.0.3"
test: "^0.12.30+2"
build_runner: "^0.7.9+2"
build_web_compilers: "^0.3.0"
sass_builder: ^1.1.2 # update for the latest version
transformers:
- $dart2js:
commandLineOptions: [--trust-type-annotations, --trust-primitives, --show-package-warnings, --dump-info, --fast-startup]
- dart_to_js_script_rewriter
For now I have no clue how to debug the problem. Any leads will be very welcome.
Thanks!
Related
I want to use the 9.0.0-dev version of the hydrated_bloc package.
If I run pub get on my pubspec.yaml:
dependencies:
flutter:
sdk: flutter
hydrated_bloc: ^9.0.0-dev.3
I get the message Latest available version is: 8.1.0
How can I get the prereleases?
That is the version found on pud.dev.
If you want to use the latest dev package you could point to the github repo instead
hydrated_bloc:
git:
url: https://github.com/felangel/bloc.git
ref: master
path: packages/hydrated_bloc/
Here's an error I'm getting when trying to save the pubspec.yaml (which automatically runs flutter pub get) (I changed the names of the packages):
Running "flutter pub get" in ravencoin_front...
Because every version of package_b from path depends on
package_c any which is forbidden, package_b from path is
forbidden. So, because package_a depends on package_b from
path, version solving failed. pub get failed (server unavailable) --
attempting retry 1 in 1 seconds...
So the question is, why is package_c forbidden? Here's what package_c looks like:
pubspec.yaml:
name: package_c
version: 1.0.0
description: Serverpod client for communication to the consent server and database.
homepage: https://github.com/.../package_c
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
serverpod_client: ^0.9.8
/lib/package_c.dart
library package_c;
export 'package:package_c/src/protocol/protocol.dart';
export 'package:serverpod_client/serverpod_client.dart';
Finally here's protocol.dart:
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: public_member_api_docs
// ignore_for_file: unnecessary_import
library protocol;
// ignore: unused_import
import 'dart:typed_data';
import 'package:serverpod_client/serverpod_client.dart';
import 'consent_class.dart';
import 'consent_document_class.dart';
export 'consent_class.dart';
export 'consent_document_class.dart';
export 'client.dart';
class Protocol extends SerializationManager {
static final Protocol instance = Protocol();
final Map<String, constructor> _constructors = {};
#override
Map<String, constructor> get constructors => _constructors;
Protocol() {
constructors['Consent'] = (Map<String, dynamic> serialization) =>
Consent.fromSerialization(serialization);
constructors['ConsentDocument'] = (Map<String, dynamic> serialization) =>
ConsentDocument.fromSerialization(serialization);
}
}
There are no errors, not sure why this package is seen as "forbidden."
Now package_b also requires other pacakges and overrides their paths, and they work just fine. so at first I thought it doesn't like the "nested paths" part of this situation, but that's not it, otherwise it would complain about the others too.
I also wondered, maybe the issue is that it has two "library" listed in the files. but I don't think that's it because if I remove the library package_c; it has the same problem.
Maybe it's as simple as this package_c not being correctly setup as a package, but I think it is, I looked up the requirements and it seems to fit from what I found.
Just for good measure let me include some of package_b pubspect.yaml:
name: package_b
description: Ravencoin wallet backend library
version: 1.0.0
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
...
package_d: ^4.0.1
...
package_c: ^1.0.0
dependency_overrides:
# causes error!
package_c:
path: ../../package_c
# works fine!
package_d:
path: ../../package_d
...
Now, Here's the really weird part. remember, package_a imports pacakge_b which imports package_c. Well, package_b works just fine, dart pub get works great. but when I run flutter pub get in package_a, the error at the top occurs. the weird thing is only package_a complains about package_c, package_b is fine with package_c... what?
I guess I should include part of the pubspec.yaml for package_a too, this is the one that causes the error:
name: package_a
description: Ravencoin wallet frontend
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+0
environment:
sdk: '>=2.14.0 <3.0.0'
dependencies:
...
flutter:
sdk: flutter
package_b: ^1.0.0
...
dependency_overrides:
package_b:
path: ../package_b
...
...
I have a plugin created using the federated approach. The problem is that the generated_plugin_registrant.dart contains an incomplete import which is pointing to the app-facing package but leaves out the dart file name and this causes an error.
import 'package:my_plugin/'; // PROBLEMATIC LINE
import 'package:my_plugin_web/my_plugin_web.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
// ignore: public_member_api_docs
void registerPlugins(Registrar registrar) {
.registerWith(registrar); // PROBLEMATIC LINE
MyPluginWeb.registerWith(registrar);
registrar.registerMessageHandler();
}
This code is in the default example app for a plugin with an unchanged default pubspec.yaml.
Here's the pubspec.yaml for the app-facing "my_plugin" package:
name: my_plugin
description: A new flutter plugin project.
version: 0.0.1
author:
homepage:
environment:
sdk: '>=2.12.0 <3.0.0'
flutter: '>=1.20.0'
dependencies:
flutter:
sdk: flutter
my_plugin_platform_interface:
path: ../my_plugin_platform_interface
my_plugin_web:
path: ../my_plugin_web
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
plugin:
platforms:
android:
package: com.example.my_plugin
pluginClass: MyPlugin
ios:
pluginClass: MyPlugin
web:
defaultPackage:
path: my_plugin_web
I've tried all the usual commands like flutter clean and recreating the project but to no avail.
Under your web definition (which Google wants in a separate project you have to specify it as
web:
pluginClass: The class name of your web class here
fileName: The file name of the file that holds your web class here
I had it has just "file" and yours is "path" which will cause this.
The issue is that plugin support for the web was not generated for a specific package or packages.
Try creating an analysis_options.dart and add these lines
analyzer:
exclude: [lib/generated_plugin_registrant.dart]
then configure your vscode/.settings.json with these lines
"dart.analysisExcludedFolders":["./yourApp/lib/generated_plugin_registrant.dart" ]
Just find the answer, basically you need to use default_package to specify your are using the integrated plugin. More here
I created an example project inside a my flutter package and inside my example project i did:
dependencies:
flutter:
sdk: flutter
my_package:
path: ../
my_package used rxdart and i received an error after run my example project
Error: Could not resolve the package 'rxdart' in
'package:rxdart/rxdart.dart'.
I ran flutter packages get but the error is still here.
I just ran into the same issue. To solve it follow these steps:
Kill your app if it's running
Run flutter clean in both your main project directory and your my_package directory
Run flutter pub get in both your main project directory and your my_package directory
Now when you build your app you should be all set.
Check first, if you added rxdart package to your pubspec.yaml as shown below:
dependencies:
flutter:
sdk: flutter
rxdart: ^0.24.1
Run flutter pub get
I am making my first Application to build an Android App with Flutter.
I am using Android Studio as IDE.
The problem is when I import the http package:
import 'package:http/http.dart' as http;
I get an error :
error: Target of URI doesn't exist: 'package:http/http.dart'.
(uri_does_not_exist at [flutter_crypto] lib\home_page.dart:3)
That's my code :
Future<List> getCurrencies() async{
String cryptoUrl = "https://api.coinmarketcap.com/v1/ticker/?limit=50";
http.Response response = await http.get(cryptoUrl);
return JSON.decode(response.body);
}
Thanks,
You need to add the HTTP dependency to pubspec.yaml as per below.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
http: ^0.12.0
With the dependency added you then need to run the following command to update/install required packages:
flutter packages upgrade
Hope this helps
Make sure you have added the dependency to pubspec.yaml
dependencies:
http: ^0.12.0
You will also need to:
flutter packages get
For any upcoming problem with importing packages from dart please go to official Dart website packages and search for needed package and you will find solution up there.
for your issue go to:
https://pub.dartlang.org/packages/http
Installing tap https://pub.dartlang.org/packages/http#-installing-tab-
follow guide steps:
In pubspec.yaml file:# dependencies
dependencies:
http: ^0.12.0
flutter:
(NB: please make sure that http & flutter or any other attribute inside dependencies are aligned as above and they are at same line)
In terminal run below command:
$flutter packages get
run: dart pub --trace get --no-precompile in android srudio Terminal