After cloning any flutter project I can not resolve dependencies? - flutter

I want to clone open source projects, I face a hole punch of errors after tapping pub get, all dependencies cannot be resolved and many of the code is out of date, so how can I overcome this?

Please use intl 0.17.0 to resolve the issue

This problem is due to the conflict between dependency versions.
You are using two dependencies that need different version of intl:
flutter_localization
openfluttercommerce
in your pubspec.yaml change the version of intl from 0.16.0 to 0.17.0. It may cause another conflict with other dependencies that may depend on 0.16.0 version of intl. If it accurs, you need to change the version of utilized dependencies to whatever need the same version of intl.

Whenever you clone the project from Github try to open it with flutter sdk version 1.17.0 or 1.22.4 after seeing the first commit of the project then the problem seems to be solved.
but here it seems that you got problem with two dependencies try to resolve that by not mentioning any version in yuml file.

Related

Flutter: Override pub package with a specific commit while retaining dependencies

We're having a problem with the flutter_html package in our project since upgrading flutter, but there's a potential fix introduced as a PR by other github user. The problem is, I can't get their changes to override the base package, namely because we also use flutter_html_table which relies on flutter_html to resolve its version with flutter pub get
Here's what I've tried using in the project's pubspec.yaml file:
flutter_html: ^3.0.0-alpha.6
flutter_html_table: ^3.0.0-alpha.3
dependency_overrides:
flutter_html:
git:
url: https://github.com/Sub6Resources/flutter_html.git
ref: 6908733505732bff93a5e7d45e822bd837c16c5b
But the changes introduced in the git commit I've referenced as a dependency_override aren't being reflected in the plugin's source code when I inspect it inside the project. This is after I've run a flutter clean to ensure cached versions weren't being used instead.
I've also tried swapping the git/pub.dev versions of the package around, but this fails to resolve when I build the project so I'm assuming it's the wrong approach.
I've also just tried running flutter pub cache repair to ensure the cache is truly wiped, but still has no effect on bringing the changes from the commit into my project.
The issue came from the fact that dependency_overrides only apply to the package that they're defined in. As my project has multiple dependencies (app, core, types, etc.) and I was defining the override in 'core', the 'app' package (which depends on 'core') used the original flutter_html package instead of the overridden one.
Moving the dependency override to my app package's pubspec.yaml resolved the issue :)

flutter The method 'File.create' has fewer named arguments than those of overridden method 'File.create'

When I try to run my Flutter project, I get errors like:
../../../.pub-cache/hosted/pub.dev/file-6.1.2/lib/src/interface/file.dart:15:16: Error: The method 'File.create' has fewer named arguments than those of overridden method 'File.create'. Future create({bool recursive = false});
Running flutter clean and flutter upgrade didn't help. What's wrong? How do I fix this?
I kept getting the same error, But I solved it adding by adding
file: ^6.1.4 in my dependencies
If you are having the same problem. Make sure you have the latest file dependency.
I think the problem is caused by an outdated reference to file dependency. See this issue.
For fix this, on the project or library folder run:
dart pub upgrade
This command will upgrade your dependencies and the problem will be solved without adding the reference to latest version of file dependency.
I just ran in to this issue and I was on flutter's master channel. I switched back to stable (flutter channel stable) and everything works fine.
For me the packages in my pubspec.yaml were all up to date, but the following fixed it:
Delete pubspec.lock.
Run flutter pub get again.
i solved it by adding file: ^6.1.4 to my pubspec i dont know why this is needed in dependenccies but when i added it worked
this error occured to me when i was trying to update my flutter and packages
but error thrown was of transitive dependencies i guess when u defin in dependencies it over rides the transitive one
but it worked for me
but after wards once project ran i removed the file dependencie from my punspec did a flutter clean and a pub get again and ran the project again it worked without any problem

Error in resolving package dependency swiftUI project

Dependencies could not be resolved because root depends on 'googleappmeasurement' 9.0.0.
'googleappmeasurement' 9.0.0 cannot be used because 'googleappmeasurement' 9.0.0 depends on 'nanopb' 2.30908.0..<2.30909.0 and root depends on 'nanopb' 2.30909.0..<2.30910.0.
that is my error message, can anyone help?
I am using SDK version 8.9.1 and everything working fine, If you executed the Resolve Package Versions and still not working. you can try the command Reset Package Caches from Project navigator scroll down right click on Package Dependencies then choose the command. that will clear all caches for all installed packages then re-install them again. if that not working i suggest you to use version 8.9.1 till Firebase fix the issue.
I have discovered the problem has been answered here. It occurs when importing Firebase using Swift Package Manager and setting to track "master" instead of a specific release version.
Got same error and solved, check attached image, this most likely packages usage misconfiguration, as follows:
1-perhaps you are working on a branch with different Xcode version than the other developer who installed the package.
2-Perhaps some package is conflicted being used twice, by so some dependencies are duplicated.
Well to solve this you gotta try either to match the Xcode version used while installing the packages, or to remove the package that makes errors(like Firebase here), and try adding that package again your side.

package conflict in flutter project

dears I am working on a flutter app where I need to add flutter_google_map V 4.0.0 and parse_server_sdk V 3.1.0 and each one depend on different version of http_package
the map depend on version 0.12.0
and parse_sdk depend on 0.13.3
there fore I am getting conflict issue
how I could resolved without done grade the versions
thanks in advance
try without versioning
flutter_google_map:
parse_server_sdk:

problem with running every flutter app from github( Because xml >=4.4.0 <4.4.1 depends on petitparser ^3.1.0 and xml )

i am new to flutter, i have already made some small projects on my system but when I clone projects from github i cant build and run these projects, and I always get errors similar to this:
Because xml >=4.4.0 <4.4.1 depends on petitparser ^3.1.0 and xml >=3.7.0 <4.4.0 depends on petitparser ^3.0.0, xml >=3.7.0 <4.4.1 requires petitparser ^3.0.0.
And because xml >=4.4.1 <5.0.0-nullsafety.1 depends on petitparser ^3.0.0, xml >=3.7.0 <5.0.0-nullsafety.1 requires petitparser ^3.0.0.
And because every version of intl_translation from git depends on petitparser ^4.0.0 and flutter_svg >=0.18.1 <0.20.0-nullsafety.0 depends on xml ^4.2.0, intl_translation from git is incompatible with flutter_svg >=0.18.1 <0.20.0-nullsafety.0.
So, because natrium_wallet_flutter depends on both flutter_svg ^0.19.3 and intl_translation from git, version solving failed.
pub get failed (1; So, because natrium_wallet_flutter depends on both flutter_svg ^0.19.3 and intl_translation from git, version solving failed.)
i have two main questions, first what are these errors and why I can't fix them by pub get, second question is how to solve this issue?
thanks for your help
These errors come from a conflict between your dependencies. It lists all the problematic dependencies and what flutter has tried to resolve them without success.
You need to update your pubspec.yml (add it to your question could help) in order to resolve the issues. This is a reason why you should be careful adding dependencies to your projects as it makes maintainability harder and in a case of a dependency being a critical component of your app, if its support is stopped it is on you to take the project on (or find another solution).
If you can you could try updating all dependencies to their latest version and then resolve potential issues with those which were not updated by they contributors (if any).
Be careful changing a major version of a dependency may lead to some refactoring required.
I don't know about intl but some people made an answer towards installing intl_utils: ^1.6.3 in this answer maybe your problems are related.