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

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/

Related

How to solve the error on outdated code when cloning

I am recently want to see and run some other developers code in github and clone it to run in my emulator but it showing some error like this
"Running "flutter pub get" in budgex...
Because budgex depends on basic_utils from path which doesn't exist (could not find package basic_utils at "..\packages\basic-utils-3.3.3"), version solving failed.
pub get failed (66; Because budgex depends on basic_utils from path which doesn't exist (could not find package basic_utils at "..\packages\basic-utils-3.3.3"), version solving failed.)"
i am was trying to install basic_utils package but seem failed how to solve this problem?
Click on the link to get packages in the given environment like VS code, or save your code while pubspec.yaml file is opened – it will get flutter packages for you automatically.
The error says that you are trying to use a library on your local computer: basic_utils; the pub command is searching it in the path ..\packages\basic-utils-3.3.3 but it can't find the library there.
In the pubspec.yaml you should have something like this:
basic_utils:
path: ..\packages\basic-utils-3.3.3
You should be ok replacing this with:
basic_utils: 3.3.3
If the developer has made changes to the library you should ask him the changed library and then update the pubspec with the correct location like described here.

Importing packages from GitHub in pubspec yaml, requires pubspec.yaml file which isnt in the repository

I have issues using flutter pub get with a repository package in my pubspec.yaml file.
dependencies:
flutter:
sdk: flutter
flutter_stripe:
git:
url: https://github.com/flutter-stripe/flutter_stripe.git
ref: poc-use-expensive-androidview
Following the steps provided https://dart.dev/tools/pub/dependencies#git-packages.
However, I am getting the error
Could not find a file named "pubspec.yaml" in https://github.com/flutter-stripe/flutter_stripe.git 7934151fefed73c6a22c253de3a1f1c9d46decc2.
pub get failed (1; Could not find a file named "pubspec.yaml" in https://github.com/flutter-stripe/flutter_stripe.git 7934151fefed73c6a22c253de3a1f1c9d46decc2.)
I have no idea what I am suppose to put for the pubspec.yaml which is not present in the repository. And it works fine if you call the package as it is using flutter pub add flutter_stripe.
The reason I am required to use an unofficial branch is because one of the fields provided by the package is not working correctly, and the suggested solution is to use this branch.
Sorry, my bad, I didnt know that the root of the Hosted package isn't the final path. I was required to add a path to the packages, which can then be found in ./packages/stripe.
flutter_stripe:
git:
url: https://github.com/flutter-stripe/flutter_stripe.git
ref: poc-use-expensive-androidview
path: ./packages/stripe
For anyone who has the same issue as me... or maybe i'm just noob
If you look at the packages of the git project you can see more then one package: https://github.com/flutter-stripe/flutter_stripe/tree/main/packages
You have to choose the package(s) you need.

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.

Getting an error when running "flutter pub get"

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

How to add a package from command line?

npm (and so yarn) has a greate feature that you can add needed packages just by knowing the package name (like yarn add xxx_yyy) and it adds the latest stable release to your project. Does flutter have any equivalent hero? Or we have to search our needed package on pub.dev and find version to add to our pubspec.yaml?
Add a package as a direct dependency:
flutter pub add <package-name>
Add a package as a dev-dependency:
flutter pub add -d <package-name>
Remove a package:
flutter pub remove <package-name>
Note: You can also use dart command instead of flutter above.
You can manage packages with flutter pub command.
flutter pub add - adds packages to your project's pubspec.yaml and downloads them. So you don't have to run flutter pub get.
flutter pub add <package>
Add a package to your project's dependencies.
flutter pub add --dev <package>
Similarly adds package to dev_dependencies.
flutter pub remove <package>
Removes the package from your project's dependencies.
Documentation: https://dart.dev/tools/pub/cmd
Note: (flutter pub is the same as dart pub)
Update 2
Based on #CopsOnRoad answer, now dart has add command which is the best way for adding packages from cmd. Full documentation is here.
Update
Right now you can have exactly similar experience like npm or yarn in flutter with the help of get_cli package. One of the tools it provides will let you just write the package name and it automatically installs the latest version with mentioning the version number inside the yaml file.
From its documentation
// To install a package in your project (dependencies):
get install camera
// To install several packages from your project:
get install http path camera
// To install a package with specific version:
get install path:1.6.4
// You can also specify several packages with version numbers
// To install a dev package in your project (dependencies_dev):
get install flutter_launcher_icons --dev
Old answer
About the cli verb add, there is no any equivalent in flutter and pub yet. But about the versioning and adding packages just with their names, try to add them in pubspec.yaml file without version number. Just like this:
dependencies:
http: ^0.12.0+2
mobx:
flutter_mobx:
dio: ^2.1.13