flutter packages get command gives an error error - flutter

hello I tried running flutter pub get and I was faced with this error:
flutter pub get
Waiting for another flutter command to release the startup lock...
Running "flutter pub get" in Deutsche-Flutter...
Because every version of flutter_test from sdk depends on test_api 0.3.0 and mockito 4.1.4 depends on test_api ^0.2.19-nullsafety, flutter_test from sdk is incompatible with mockito 4.1.4.
And because no versions of mockito match >4.1.4 <5.0.0, flutter_test from sdk is incompatible with mockito ^4.1.4.
So, because deutsche depends on both mockito ^4.1.4 and flutter_test any from sdk, version solving failed.
pub get failed (1; So, because deutsche depends on both mockito ^4.1.4 and flutter_test any from sdk, version solving failed.)
exit code 1
I already ran flutter upgrade and tried to run flutter pub get here are my dependencies:
environment:
sdk: ">=2.7.0 <3.0.0"
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: ^1.0.0
flutter_svg: ^0.19.1
flutter_bloc: ^6.1.2
get: ^3.23.1
rxdart: ^0.19.0
http: ^0.12.2
google_fonts: ^0.3.9
circular_countdown_timer: ^0.1.0
pin_code_fields: ^2.4.0
google_nav_bar: ^3.2.0
line_icons: ^0.2.0
shared_preferences: ^0.5.12+4
flutter_launcher_icons: ^0.7.2+1
rive: ^0.6.8
timer_count_down: ^1.0.4+1
logger: ^0.9.4
dartz: ^0.9.0-dev.6
freezed_annotation: ^0.12.0
bloc_test: ^7.1.0
mockito: ^4.1.4
jwt_decode: ^0.3.1
carousel_slider: ^3.0.0
dev_dependencies:
build_runner:
freezed: ^0.12.7
flutter_test:
sdk: flutter

Update all of your plugins and that will work. And do make sure that all of them are null-safety enabled.

try replacing mokito version as any as follows.
mockito: any
then check the pubspeck.lock file and search mokito and take that version number from there and replace it in pubspec.yaml file

update the mockito package to => mockito: ^5.2.0

Related

every version of flutter_test from sdk depends on test_api 0.4.8, mockito >=4.1.2 <=5.0.0-nullsafety.7 is incompatible with flutter_test from sdk

pubspec.yaml:
name: my_chat_app
description: A new Flutter application.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
chat:
path: ./chat
sqflite: ^2.0.0+3
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^4.1.4
flutter_lints: ^1.0.0
# The following section is specific to Flutter.
flutter:
chat/pubspec.yaml:
name: chat
description: A new Flutter package project.
environment:
sdk: ">=2.16.1 <3.0.0"
flutter: ">=1.17.0"
dependencies:
flutter:
sdk: flutter
rethinkdb_dart: ^2.3.2+6
encrypt: ^4.0.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter:
flutter pub get output in pubspec.yaml:
Running "flutter pub get" in my_chat_app...
Because mockito >=4.1.2 <=5.0.0-nullsafety.7 depends on test_api ^0.2.19-nullsafety and every version of flutter_test from sdk depends on test_api 0.4.8, mockito >=4.1.2 <=5.0.0-nullsafety.7 is incompatible with flutter_test from sdk.
So, because my_chat_app depends on both flutter_test from sdk and mockito ^4.1.4, version solving failed.
pub get failed (1; So, because my_chat_app depends on both flutter_test from sdk and mockito ^4.1.4, version solving failed.)
Process finished with exit code 1

Flutter - v 1.24.0 to 2.0.5 - pubspec.yaml version problems

I have downloaded flutter_windows_2.0.5-stable.zip and installed Flutter 2.0.5.
When I run a v1.24.0 project, I get the following output:
Running "flutter pub get" in get_json ...
The current Dart SDK version is 2.12.0-29.10.beta.
Because flutter_easyloading 3.0.0 requires SDK version >=2.12.0 <3.0.0 and no versions of flutter_easyloading match >3.0.0 <4.0.0, flutter_easyloading ^3.0.0 is forbidden.
So, because get_json depends on flutter_easyloading ^3.0.0, version solving failed.
pub get failed (1; So, because get_json depends on flutter_easyloading ^3.0.0, version solving failed.)
Contents of pubspec.yaml:
dependencies:
flutter:
sdk: flutter
http: ^0.12.2
json_annotation: ^2.0.0 #^4.0.1
rflutter_alert: ^1.1.0 #^2.0.2
pdf_flutter: ^1.1.4
syncfusion_flutter_pdfviewer: ^18.4.49-beta
webview_flutter: ^1.0.7 #^2.0.4
flutter_easyloading: ^3.0.0
cupertino_icons: ^1.0.1
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^1.0.0
json_serializable: ^2.0.0 #^4.1.1
Looking around the Internet I found
Update to/install latest Flutter packages (pubspec.yaml)
At the end of this it is stated that in Flutter 2 it will help to run
1 flutter pub outdated and
2 flutter pub upgrade --major-versions
Running 1 "flutter pub outdated" gives a looot of output and ends with:
Changed 75 dependencies!
25 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
No changes to pubspec.yaml!
Running 2 "flutter pub upgrade --major-versions" also gives a lot of output and ends with:
...
No dependencies changed.
25 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Changed 4 constraints in pubspec.yaml:
json_annotation: ^2.0.0 -> ^4.0.1
rflutter_alert: ^1.1.0 -> ^2.0.2
webview_flutter: ^1.0.7 -> ^2.0.4
json_serializable: ^2.0.0 -> ^4.1.1
pubspec.yaml was changed to:
dependencies:
flutter:
sdk: flutter
http: ^0.12.2
json_annotation: ^4.0.1 #^4.0.1
rflutter_alert: ^2.0.2 #^2.0.2
pdf_flutter: ^1.1.4
syncfusion_flutter_pdfviewer: ^18.4.49-beta
webview_flutter: ^2.0.4 #^2.0.4
flutter_easyloading: ^3.0.0
cupertino_icons: ^1.0.1
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^1.0.0
json_serializable: ^4.1.1 #^4.1.1
Now I try run my (old) project again which results in the following output:
Running "flutter pub get" in get_json...
The current Dart SDK version is 2.12.0-29.10.beta.
Because no versions of json_serializable match >4.1.1 <5.0.0 and json_serializable 4.1.1 requires SDK version >=2.12.0 <3.0.0, json_serializable ^4.1.1 is forbidden.
So, because get_json depends on json_serializable ^4.1.1, version solving failed.
pub get failed (1; So, because get_json depends on json_serializable ^4.1.1, version solving failed.)
I have tried many variations of what is described above, but I am stuck.
Can anyone help or guide me in the right direction? Thank you.
==============================
Thank you to Ujjwal Raijada. I got Flutter 2 because of web support and did not think of null safety. However, I have now followed the migration guide to the detail and now have the following pubspec.yaml:
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
http: ^0.13.1
json_annotation: ^4.0.1
rflutter_alert: ^2.0.2
#pdf_flutter: ^1.1.4 # Package pdf_flutter is not null safe and therefore cannot be used ...
syncfusion_flutter_pdfviewer: ^19.1.57-beta
webview_flutter: ^2.0.4
flutter_easyloading: ^3.0.0
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.0.1
json_serializable: ^4.1.1
I have also changed my code as suggested by the migration guide. so now I run "flutter packages pub run build_runner build" which results in:
The pubspec.yaml file has changed since the pubspec.lock file was generated, please run "pub get" again.
pub finished with exit code 65
Pressing "pub get" in pubspec.yaml gives the following result:
The current Dart SDK version is 2.12.0-29.10.beta.
Because get_json requires SDK version >=2.12.0 <3.0.0, version solving failed.
pub get failed (1; Because get_json requires SDK version >=2.12.0 <3.0.0, version solving failed.)
Process finished with exit code 1
What should I do now? Any help out there? Thank you.

Because every version of flutter_driver from sdk depends on crypto 3.0.0 and Cruise depends on crypto 2.1.3, flutter_driver from sdk is forbidden

When I compile my project, it shows this error:
Running "flutter pub get" in cruise-open...
Because every version of flutter_driver from sdk depends on crypto 3.0.0 and Cruise depends on crypto 2.1.3, flutter_driver from sdk is forbidden.
So, because Cruise depends on flutter_driver any from sdk, version solving failed.
pub get failed (1; So, because Cruise depends on flutter_driver any from sdk, version solving failed.)
I have tried each version of crypto but still not fix my problem, what should I do to solve it? This is my pubspec.yaml:
name: Cruise
description: A RSS article read Flutter application.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: 0.16.1
meta: ^1.1.8
flutter_svg: 0.19.0
logger: 0.9.4
marquee: ^1.7.0
scoped_model: ^1.1.0
shrine_images: ^1.1.2
flare_dart: 2.3.4
flare_flutter: ^2.0.2
vector_math: ^2.0.8
collection: ^1.14.0
package_info: ^0.4.0
fluttertoast: 7.1.6
google_fonts: 1.0.0
flutter_staggered_grid_view: ^0.3.0
adaptive_breakpoints: ^0.0.2
cupertino_icons: 1.0.0
http: ^0.12.0+2
flutter_icons: ^1.0.0
timeago: 2.0.26
animations: 1.1.2
flutter_hooks: ^0.12.0
share: ^0.6.4+3
shimmer: 1.1.1
crypto: 2.1.3
url_launcher: 5.5.0
uni_links: 0.4.0
flutter_html: 1.2.0
shared_preferences: ^0.5.8
state_notifier: ^0.5.0
flutter_secure_storage: 3.3.3
flutter_slidable: "^0.5.5"
hive: ^1.4.1+1
#fluwx: ^2.4.1
pull_to_refresh: 1.6.3
intl_phone_number_input: ^0.5.0
dio: 3.0.10
fish_redux: 0.3.4
hive_flutter:
git:
url: https://github.com/hivedb/hive.git
path: hive_flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
test:
path:
args:
grinder: ^0.8.0
pedantic: ^1.9.0
string_scanner: ^1.0.5
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
generate: true
The problem lies here crypto: 2.1.3. You need to update it to the latest version i. e. crypto: ^3.0.0.
This should solve your issue.
What happens is that when you use so many packages, some of those packages use some other packages. It may so happen that two or more packages use the same package.
In your case, the package flutter_driver uses the package crypto. And you yourself are using the package crypto but a different version of it. So, it creates an error because you cannot have two different versions of the same package.

pub get failed:version solving failed

Flutter_test depends on meta 1.1.8 and firebase_login depends on meta ^1.2.2.
firebase_login depends on flutter_test any from sdk, version solving failed.
pub get failed
pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
firebase_auth: ^0.18.0+1
equatable: ^1.2.4
google_sign_in: ^4.5.3
meta: ^1.2.2
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
lint: any
You can get both by
dependencies:
meta: ^1.2.2
dependency_overrides:
meta: ^1.1.8
I have same problem with bloc:
Because every version of passcode_navigator from git depends on flutter_bloc ^7.3.3 and every version of feature_menu from path depends on flutter_bloc ^8.0.0, passcode_navigator from git is incompatible with feature_menu from path
I resolve it with adding to pubspec:
dependency_overrides:
flutter_bloc: any
Do this,
meta: ^1.1.8
And then, run this,
flutter pub get
hi there try to downgrade the version of meta to 1.1.8 i tried and it worked with me in flutter 1.20.1
I experienced a similar issue with Firebase auth and permission_handler:
# pubspec.yaml:
dependencies:
flutter:
sdk: flutter
firebase_auth: ^1.4.1
permission_handler: ^5.1.0+2
The error message (truncated):
Because permission_handler ^5.1.0 depends on permission_handler_platform_interface ^2.0.2 which depends on plugin_platform_interface ^1.0.2, permission_handler ^5.1.0 requires plugin_platform_interface ^1.0.2.
And because firebase_auth 1.4.1 depends on firebase_core_platform_interface ^4.0.1 and no versions of firebase_auth match >1.4.1 <2.0.0, permission_handler ^5.1.0 is incompatible with firebase_auth ^1.4.1.
So, because my_flutter_project depends on both firebase_auth ^1.4.1 and permission_handler ^5.1.0+2, version solving failed.
A solution that worked for me:
Update permission_handler to the latest version:
flutter pub add permission_handler
Update meta to 1.2.2
meta: ^1.2.2
also update flutter using flutter upgrade command
flutter upgrade

Flutter image version issue

I have just upgraded my flutter version and now I am facing the following issue when I get the packages in pubsec.yml file:
Because every version of flutter_test from sdk depends on image 2.1.4 and Instant_Feedback depends on image ^2.1.9, flutter_test from sdk is forbidden.
So, because Instant_Feedback depends on flutter_test any from sdk,
version solving failed. pub get failed (1; So, because
Instant_Feedback depends on flutter_test any from sdk, version solving
failed.)
My pubsec.yml file
dependencies:
flutter:
sdk: flutter
http: ^0.12.0+2
shared_preferences: ^0.5.4+8
firebase_messaging: ^6.0.3
flutter_crashlytics: ^1.0.0
firebase_core: ^0.4.2+1
cupertino_icons: ^0.1.3
device_calendar: ^1.0.0+2
cloud_firestore: ^0.12.11
auto_size_text: ^2.1.0
flutter_expandable_menu: ^0.0.1
webview_flutter: ^0.3.17
flutter_spinkit: ^4.1.1+1
get_it: 2.1.0
bloc: ^0.15.0
flutter_bloc: 0.21.0
equatable: 0.5.1
rflutter_alert: ^1.0.3
expandable: ^3.0.1
connectivity: ^0.4.6
firebase_auth: ^0.15.1
flutter_email_sender: ^2.2.1
mockito: 4.1.1
flutter_secure_storage: ^3.3.1+1
image_picker: ^0.6.2+2
async: any
image: ^2.1.10
image_crop: ^0.3.1
flutter_cache_manager: ^1.1.3
circular_profile_avatar: ^1.0.3
package_info: ^0.4.0+12
flutter_local_notifications: ^0.8.4+3
flutter_webview_plugin: ^0.3.10
url_launcher: ^5.2.7
flutter_localizations:
sdk: flutter
flutter_cupertino_localizations: ^1.0.1
dev_dependencies:
flutter_driver:
sdk: flutter
test: any
ozzie: 2.0.1
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- lib/app/assets/images/
- lib/app/assets/flags/
- lang/en.json
- lang/de.json
Because every version of flutter_test from sdk depends on image 2.1.4 and Instant_Feedback depends on image ^2.1.9, flutter_test from sdk is forbidden.
I faced the same issue. Couldn't find the specific reason for the flutter_test depending on a specific version of this image library. Maybe it's an issue from the flutter side. So here are some workaround solutions:
comment out the flutter_test dev_dependency.
dev_dependencies:
# flutter_test:
# sdk: flutter
set the required version.
Instead of 2.1.12, I set the Image package version to 2.1.4 (as requested in the error message)
image: ^2.1.4
If more than one packages versions are noncompatible to each other, and you don't know their exact compatible version, you can find it by setting both the conflicting dependencies to any, e.g.
flutter_crashlytics: any
firebase_core: any
This will automatically figure out the compatible package version. Check these new compatible versions in pubspec.lock file, which will be auto-generated by running flutter package get.
# Generated by pub
# See https://www.dartlang.org/tools/pub/glossary#lockfile
packages:
flutter_crashlytics:
...
version: "1.0.0"
firebase_core:
...
version: "0.4.2+1"
Replace any with those correct versions.
flutter_crashlytics: 1.0.0
firebase_core: 0.4.2+1
Note: You should never leave your versions as any