Flutter dependency conflict (versions depend on another ) - flutter

I want to add avtar in my App but not able to do this because of dependency conflict/ required version error. I also trying to override dependency but its still not working. also trying this commands.
Flutter clean
Flutter pub get
But still not working.
ERROR:-
Because no versions of random_avatar match >0.0.7 <0.1.0 and random_avatar 0.0.7 depends on flutter_svg ^1.0.3, random_avatar ^0.0.7 requires flutter_svg ^1.0.3.
And because flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1 depends on flutter_svg >=0.22.0 <1.0.0, random_avatar ^0.0.7 is incompatible with flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1.
So, because seedwill_demo depends on both flutter_html ^2.2.1 and random_avatar ^0.0.7, version solving failed.
pub get failed (1; So, because seedwill_demo depends on both flutter_html ^2.2.1 and random_avatar ^0.0.7, version solving failed.)

I guess You working on Flutter 2, but Flutter 3 is released. On pub, some libraries are default compatible with Flutter 3. In this case, not always newest library is the best option. You must find which library is incompatible. Can You put pubspec.yaml to this post? We need TWO version of pubspec.yaml. Previous (which have no error with pub get) and new, with this new library. If You show them, I try find the best version of library for You.

I had problems that look alike, and somehow managed to eliminate them by upgrading flutter parts (updating or reinstalling). Have you tried following commands?
flutter clean
flutter upgrade
flutter pub upgrade

Related

Dependencies error 1 not solivng problem google_maps

I'm trying to upgrade all the dependencies, but this error is still shown. I have tried to override them but shows a no privileges error. I already tried to run flutter pub cache repair, flutter pub get, and not sure if I need to delete the cache or maybe reinstall flutter in another file, please any suggest could help.
Because google_map_polyline >=0.0.4 <0.2.0 depends on google_maps_flutter ^0.5.21+4 and google_map_polyline <0.0.4 depends on google_maps_flutter ^0.5.19+2, google_map_polyline <0.2.0 requires google_maps_flutter ^0.5.19+2.
And because google_map_polyline >=0.2.0 depends on google_maps_flutter ^0.5.21+6, every version of google_map_polyline requires google_maps_flutter ^0.5.19+2.
So, because fletgo_user_app depends on both google_maps_flutter ^2.1.0 and google_map_polyline any, version solving failed.
pub get failed (1; So, because fletgo_user_app depends on both google_maps_flutter ^2.1.0 and google_map_polyline any, version solving failed.)
Process finished with exit code 1
The error appears because google_map_polyline is set to 'any'. But the real problem appear because google_map_polyline is already discontinued.
I suggest you change the library and migrate using the flutter_polyline_points

Conflict between dependencies when adding a new one

These were my dependencies in my pubspec.yaml:
dependencies:
...
image_picker: ^0.8.4+2
...
And everything worked fine, but now I added this:
dependencies:
...
image_picker: ^0.8.4+2
...
image_editor_pro: ^1.1.8
And running pub get I have this error:
Because image_editor_pro >=1.1.0 depends on image_picker ^0.7.4 and provauth depends on image_picker ^0.8.4+2, image_editor_pro >=1.1.0 is forbidden.
So, because provauth depends on image_editor_pro ^1.1.8, version solving failed.
pub get failed (1; So, because provauth depends on image_editor_pro ^1.1.8, version solving failed.)
I tried downgrading my version of image_picker but I get a new error:
Cannot open file, path = 'C:\Users\loren\flutter.pub-cache_temp\dir60565baa\test\fixtures\invalid\n_structure_<.>.json' (OS Error: Syntax of the name of the file, of the directory or of volume is not correct (This is my bad translation of the error).
, errno = 123)
pub get failed (66; , errno = 123))
What can I do to solve and use both the dependencies?
You can try to override the dependency so only one version is used for your project. Something like this:
name: your_app
dependencies:
image_picker: ^0.8.4+2
image_editor_pro: ^1.1.8
dependency_overrides:
image_picker: '0.8.4+2' # Use only this version for all the code depended on image picker
But you need to thoroughly tested the library that depends on the overrided dependency to check if it not introducing you a new error.
See https://dart.dev/tools/pub/dependencies#dependency-overrides
Seems like there is a conflict with image_editor_pro because the package is old.
It is better to look for another updated package with null safety, like image_editor 1.0.2, this won't have conflictions with image_picker 0.8.4+1.
And if you are willing to downgrade. ## Downgrading is a pain
You might need to downgrade the other dependencies as well. which might lead to Downgrading the Dart version.
After downgrading execute this command:
flutter clean
Then delete pubspec.lock file.
If a conflict between dependencies occurs, the simplest solution is to remove the version numbers of the two dependencies and then replace them with 'any' without the quotes in front of it. Then run pub get.
Hope you can help

Flutter easy_localization and intl version solving failed

I'm getting this error after updating flutter to version 1.25.0-8.1.pre-
Because `easy_localization` >=2.1.0+1 depends on `flutter_localizations` any from sdk which depends on `intl` 0.17.0-nullsafety.2, `easy_localization` >=2.1.0+1 requires `intl` 0.17.0-nullsafety.2.
So, because news_app depends on both `easy_localization` ^2.3.3 and `intl` ^0.16.1, version solving failed.
pub get failed (1; So, because news_app depends on both `easy_localization` ^2.3.3 and `intl` ^0.16.1, version solving failed.)
I have easy_localization 2.3.3, intl 0.16.0 and dart 2.12.0 installed. Please help
Basically what's happening is easy_localization uses a package which uses a newer version of intl. Basically, you're asking the package manager to handle two versions of the same package, there are two solutions.
Downgrade easy_localization package to a version which uses the same intl version (not recommended)
Upgrade your intl version to 0.17.0-nullsafety.2 (recommended, but null safecty is still in beta so you have to be aware of that)
Have a good day!
I think this is the best way to solve this,
You need to switch your flutter channel to a stable version, by running
flutter channel stable
in the command line. This will switch your channel to a stable version and will get rid of the error.
I hope this best solves your issue.

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.

Because every version of flutter_test from sdk depends on... flutter_test from sdk is forbidden, version solving failed

I'm having this issue when I've added http dependency in my flutter project. Can anyone please help me with it?
If you get the message:
Because every version of flutter_test from sdk depends on...
It means flutter_test depends on a dependency with version lower than you specified in another dependency.
To solve this, open pubspec.yaml, and remove the version number of the problem dependency:
Example:
Change
archive: ^2.0.13 --> remove this number
To:
archive:
You have provided or trying to use http: ^0.12.0 dependency on implementing API calls in pubspec.yaml file but flutter_test will require http: ^0.11.3+17. That's why it fails. Please replace
dependencies:
flutter:
sdk: flutter
http: ^0.12.0
with
dependencies:
flutter:
sdk: flutter
http: ^0.11.3
Hope it will help you out.
In my case, I somehow deleted sdk: flutter:
dependencies:
flutter:
sdk: flutter
I was facing a similar error. I solved it by removing all the version numbers from the dependencies: section in pubspec.yaml.
So, if my pubspec.yaml looked like this before:
dependencies:
freezed_annotation: ^0.14.3
I changed it to this:
dependencies:
freezed_annotation:
I'm assuming this fetches the latest "possible" version of each package.
Can you please provide the dependencies in your pubspec.yaml? It looks like your app depends on at least http 0.12.0 but flutter_test specifically requires http 0.11.3+17 (an older version) which makes it fail.
If your app doesn't have too many dependencies that could broke, you can try to upgrade your Flutter version: flutter upgrade.
It most probably will fix this problem. But always be sure to understand that your app might break at unexpected places.
So you're fine if:
either you're doing it for small app
or it's big app at work and it has extensive tests that will tell you something has broken
if big app without tests, be sure to test every important place of the app, where dependencies are being used
Try to change the dependency version that you were added in your pubspec.yaml file
don't use the current or latest version try some previous versions of dependency.
for ex - if you are using latest sqflite version then chnage to previous version of that and then re-run your whole project.
In my case IDE referred to an an older version of dart because of fvm. Seems like 'run' button called fvm flutter run, but not flutter run as I expected. After I deleted fvm folder from the project the problem has gone.
Change depending attributes version inside pubspec.yaml
if it says depands on http *** than change http version
or if it says depands on collection *** than change collection version.