Getting an error when running "flutter pub get" - flutter

I have cloned a Repo of a Flutter project from my developer who has the App working perfectly on his machine, and opened the project in VS Code. I did flutter clean, then flutter pub get, and am getting an error as shown below. AFAIK when I clone the repo, I should get his exact files, so I don't understand how I am getting this error, but he does not? Does anyone know how to fix this? TIA for any and all help.
Because every version of charts_flutter from git depends on logging ^1.0.2 and signalr_client >=0.1.3 depends on logging ^0.11.3+2, charts_flutter from git is incompatible with signalr_client >=0.1.3.
So, because app1 depends on both signalr_client ^0.1.6 and charts_flutter from git, version solving failed.
Running "flutter pub get" in App1...
pub get failed (1; So, because app1 depends on both signalr_client ^0.1.6 and charts_flutter from git, version solving failed.)

The reason is simple
The both two packages depends on one common package
Signalr_client & Charts Flutter packages needs the logging package as a dependency.
See the pubspec file
https://github.com/soernt/signalr_client/blob/master/pubspec.yaml
https://github.com/google/charts/blob/master/charts_flutter/pubspec.yaml
But the versions are different for that.
Solution:
Try to remove the logger package from the pub_cache folder.
remote any one package signalr_client or charts_flutter.
use syncfusion_charts instead of charts_flutter
Try to update the flutter packages

Related

Flutter - how to use packages outside pub.dartlang.org

I'm trying to use flutterfire_ui for authentication in a flutter app. The developer (invertase) has committed a pull request 9343 on github that fixes some problems. I have pulled it into a local GIT folder. It includes some reorganization of folders, including a package name change - firebase_ui_auth instead of flutterfire_ui. I have changed my local pubspec.yaml to use all the firebase packages in PR 9343 but I get an error with "pub get" as follows that I am unable to resolve.
Running "flutter pub get" in firebase_with_flutter...
Because every version of firebase_ui_oauth from path depends on firebase_ui_auth from hosted and firebase_with_flutter depends on firebase_ui_auth from path, firebase_ui_oauth from path is forbidden.
So, because firebase_with_flutter depends on firebase_ui_oauth from path, version solving failed.
pub get failed (1; So, because firebase_with_flutter depends on firebase_ui_oauth from path, version solving failed.)
In pubspec.yaml I have entered an explicit path to all of the PR9343 firebase packages
firebase_core:
path: C:/GP/project/git-remote/flutterfire/packages/firebase_core/firebase_core/
cloud_firestore:
path: C:/GP/project/git-remote/flutterfire/packages/cloud_firestore/cloud_firestore/
firebase_auth:
path: C:/GP/project/git-remote/flutterfire/packages/firebase_auth/firebase_auth/
firebase_ui_auth:
path: C:/GP/project/git-remote/flutterfire/packages/firebase_ui_auth/
firebase_ui_oauth:
path: C:/GP/project/git-remote/flutterfire/packages/firebase_ui_oauth/
In main.dart android studio reports "invalid URI" for this import
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
https://github.com/firebase/flutterfire/tree/master/packages/flutterfire_ui
Does anyone have any idea what I am doing wrong?
If I add explicit paths to the pubspec.yaml files in my local git repo just as I have for my own pubspec.yaml file then it works and pub get runs without error. So now I have this
firebase_auth:
path: C:\GP\project\git-remote\flutterfire\packages\firebase_auth\firebase_auth\
instead of this
firebase_auth: ^3.6.2
How come it works for the Invertase developer without using path settings and not for me. As well as that, the firebase_auth package is in a "deeper folder"
C:\GP...\packages\firebase_auth\firebase_auth\ than it was before and if I leave off the inner \firebase_auth from the path it doesn't work.
Maybe I'm supposed to use the git mechanism instead of an explicit path setting.

Trying to do a flutter pub get and got Process finished with exit code 66

Running "flutter pub get" in mobile...
Because mobile depends on charts_flutter from path which doesn't exist (could not find package charts_flutter at "../mobile-dependencies/pub.dartlang.org/charts_flutter-0.12.0"), version solving failed.
pub get failed (66; Because mobile depends on charts_flutter from path which doesn't exist (could not find package charts_flutter at "../mobile-dependencies/pub.dartlang.org/charts_flutter-0.12.0"), version solving failed.)
Process finished with exit code 66
/Users/H025712/development/flutter/bin/flutter --no-color pub get
Running "flutter pub get" in mobile...
Because mobile depends on charts_flutter from path which doesn't exist (could not find package charts_flutter at "../mobile-dependencies/pub.dartlang.org/charts_flutter-0.12.0"), version solving failed.
pub get failed (66; Because mobile depends on charts_flutter from path which doesn't exist (could not find package charts_flutter at "../mobile-dependencies/pub.dartlang.org/charts_flutter-0.12.0"), version solving failed.)
Cause: Someone in your team (could be yourself) add a plugin from their local folder. This plugin can't be found when you try to update the dependency.
Quick fix: If you use remote git, let you teammate include that plugin in the project folder, modify the pubspec.yaml path, add it to stage, commit then push. In the case not using git remote, copy those files to your computer in the path as pub spec.yaml suggested.
Ideal fix: Let your teammate use public plugin or share that plugin in private with password, then let flutter download that plugin by flutter pub get/upgrade.
Check your pubspec.yaml is well ordered, I had badly composed dev_dependencies and it failed me
Talked to my tech lead, who is familiar with the code; he said to check out the missing code that was referencing overrides in the pubspec.yaml:
https://dart.dev/tools/pub/dependencies
Dependency overrides
You can use dependency_overrides to temporarily override all references to a dependency.
For example, perhaps you are updating a local copy of transmogrify, a
published library package. Transmogrify is used by other packages in
your dependency graph, but you don’t want to clone each package
locally and change each pubspec to test your local copy of
transmogrify.
In this situation, you can override the dependency using
dependency_overrides to specify the directory holding the local copy
of the package.
The pubspec would look something like the following:
name: my_app
dependencies:
transmogrify: ^1.2.0
dependency_overrides:
transmogrify:
path: ../transmogrify_patch/

Differences dart pub get and flutter pub get

I have been using flutter pub get for updating pubspect.yaml
Now I have found that there is a similar command dart pub get
What are the differences between these two commands?
Using the command flutter pub get you are getting dart packages for Flutter.
Using dart pub get you are getting Dart packages.
You can create dart projects without Flutter and there you’ll need use the command dart pub get.
Every Flutter project is a Dart project
but not every Dart project is a Flutter project, because Flutter is a UI kit or framework for building UIs in the Dart programming language.
When dart pub get gets new dependencies, it writes a lockfile to ensure that future gets will use the same versions of those dependencies. Application packages should check in the lockfile to source control; this ensures the application will use the exact same versions of all dependencies for all developers and when deployed to production. Library packages should not check in the lockfile, though, since they’re expected to work with a range of dependency versions.
If a lockfile already exists, dart pub get uses the versions of dependencies locked in it if possible. If a dependency isn’t locked, pub gets the latest version of that dependency that satisfies all the version constraints. This is the primary difference between dart pub get and dart pub upgrade, which always tries to get the latest versions of all dependencies.
When running flutter pub get (Packages get in IntelliJ or Android Studio) for the first time after adding a package, Flutter saves the concrete package version found in the pubspec.lock lockfile. This ensures that you get the same version again if you, or another developer on your team, run flutter pub get.

Flutter Riverpod: pub get failed

I'm currently trying to study using flutter riverpod but i get a problem when i'm trying to put flutter_riverpod package i get this error
Because riverpod depends on flutter_riverpod ^0.9.1 which depends on riverpod ^0.8.0, riverpod ^0.8.0 is required.
So, because riverpod is 1.0.0+1, version solving failed.
Running "flutter pub get" in riverpod...
pub get failed (1; So, because riverpod is 1.0.0+1, version solving failed.)
What can i do to fix this problem? I tried to add riverpod package but it's also not working
I think you should open your pubspec.yaml
at first line. probably your name is riverpod
My issue as well like you. name was flutter_riverpod
Check if your project name is riverpod
For me, that was the issue...
Just use a different name for your project.
See this decision tree created by the developer of riverpod for which version to install.
You only want to install one riverpod dependency.
In short, if you are using flutter_hooks (which I would personally recommend), install hooks_riverpod. If you are not using hooks, install flutter_riverpod.
If you are writing pure dart code (no Flutter), then install riverpod.
To reiterate, your pubspec.yaml should only ever include one riverpod dependency.
If you still have version solving issues with your dependencies after this then try deleting your pubspec.lock and reinstall your dependencies.

How to update pub package webdev for flutter web

when I try to "serve" my flutter web app
I'm getting this error:
This version of webdev does not support the build_daemon protocol
used by your version of build_runner. A newer version of webdev is
available which supports your version of the build_daemon. Please
update.
how do I update webdev ?
"pub global" seems to offer only "activate"/ "deactivate"
and "pub upgrade" is only looking into the pubspec.yaml file
any idea?
Oh... I just run "pub global deactivate " and then "pub global activate ".
Anyway I opened an issue on github suggesting to add the feature "update".
I hope this easy solution might help you,
feel free to follow up the issue.
Adding build_daemon: ^1.0.0 in dev_dependencies: of .yaml file fix my error
Do not use a global version, but use a per-project version.
To ensure running webdev on your project always works, include the version of webdev it requires in the pubspec.yaml file:
dev_dependencies:
webdev: ^2.7.9
...
And run it using:
$ dart run webdev ...
This ensures the correct version of webdev is installed when dart pub get is run, and that particular version is used for the project.
This avoids having to update the global version when things change. Running dart pub global deactivate webdev and dart pub global activate webdev is unnecessary work.
Globals are bad. Using "dart pub global activate ..." installs only one version of webdev, which may become out-of-date with your project (as you've discovered). Or you might have multiple Dart projects, and they require different versions of webdev. The above approach uses a per-project version of webdev, ensuring it is always the correct version for the project.
I got the same problem now when I followed this tutorial https://medium.com/flutter-community/flutter-create-and-deploy-a-website-from-scratch-4a026ebd6c, but I didn't get pass the error by running flutter pub global activate.
Here is what i configured in my computer
run: pub get
run: webdev serve
dev_dependencies:
build_daemon: ^1.0.0
build_runner: ^1.4.0
build_web_compilers: ^2.0.0
Wish this will fix your issues.
I had to use the following command to update webdev
flutter pub global run webdev deactivate
and then
flutter pub global run webdev activate