How to resolve version conflicts between packages? - flutter

I'm making a function to record voice and save it as a file. However, an error occurred when pub get to the pubspec.yaml file.
Because every version of flutter_audio_recorder depends on file ^5.0.4 and shared_preferences_windows >=2.0.0 depends on file ^6.0.0, flutter_audio_recorder is incompatible with shared_preferences_windows >=2.0.0.
And because shared_preferences 2.0.9 depends on shared_preferences_windows ^2.0.0 and no versions of shared_preferences match >2.0.9 <3.0.0, flutter_audio_recorder is incompatible with shared_preferences ^2.0.9.
So, because mirinae_gugu depends on both shared_preferences ^2.0.9 and flutter_audio_recorder ^0.5.5, version solving failed.
pub get failed (1; So, because mirinae_gugu depends on both shared_preferences ^2.0.9 and flutter_audio_recorder ^0.5.5, version solving failed.)
The package I am using is below.
cupertino_icons: ^1.0.2
provider: ^6.0.0
carousel_slider: ^4.0.0
rxdart: ^0.27.2
font_awesome_flutter: ^9.1.0
shared_preferences: ^2.0.9
flutter_signin_button: ^2.0.0
image_picker: ^0.7.0
path_provider: ^2.0.2
sizer: ^2.0.15
get: 3.24.0
flutter_svg: ^0.19.1
intl: ^0.17.0
cached_network_image: ^3.1.0
camera: ^0.9.2
google_speech: ^2.0.1
sound_stream: ^0.3.0
flutter_animation_progress_bar: ^2.0.1
noise_meter: ^3.0.2
rflutter_alert: ^2.0.2
audioplayers: ^0.19.1
fluttertoast: ^8.0.7
share: ^2.0.4
permission_handler: ^8.1.4+1
flutter_audio_recorder: ^0.5.5
Even though I fixed the error between flutter_audio_recorder and shared_preferences, I still get the error between different packages.
How can I solve this?

Run flutter clean. Then
In pubspec.yaml give
audioplayers: any
Delete pubspec.lock. Then run flutter pub get and flutter run. It should work as expected

Use flutter_audio_recorder2 instead. This is an exact clone of flutter_audio_recorder but it supports dart null-safety support.
flutter_audio_recorder2: ^0.0.2
Not Recommended Solution (using old flutter_audio_recorder package).
Below is the solution using flutter_audio_recorder. This is the opened pull request #58 - Added sound null safety support. So you can use it like below
Change the flutter_audio_recorder dependencies like below
flutter_audio_recorder:
git:
url: git://github.com/fayeed/flutter_audio_recorder.git
ref: sound-null-safety

Use dependency override, suppose some_package and another_package depends on incompatible url_launcher version, you can resolve conflict this way:
dependencies:
some_package:
another_package:
dependency_overrides:
url_launcher: '5.4.0'

Related

dependency issues why I try to run/debug my app

I'm new to making an app with flutter/dart and I'm running into some issues with the dependecies in the pubspec.yaml. I'm trying to make an app from a template to learn about how to work with repositories from github. After I brought in the code and repaired all the errors I tried to run/debug it and keep getting this from the output terminal:
Because google_sign_in >=5.4.0 depends on google_sign_in_platform_interface ^2.2.0 which depends on quiver ^3.0.0, google_sign_in >=5.4.0 requires quiver ^3.0.0.
And because cloud_firestore >=0.14.0-dev.1 <0.17.0-1.0.nullsafety.0 depends on quiver ^2.0.0, google_sign_in >=5.4.0 is incompatible with cloud_firestore >=0.14.0-dev.1 <0.17.0-1.0.nullsafety.0.
Because cloud_firestore >=0.13.3 <0.14.0-dev.1 depends on firebase_core ^0.4.4 and cloud_firestore >=0.11.0 <0.13.3 depends on firebase_core ^0.4.0, cloud_firestore >=0.11.0 <0.14.0-dev.1 requires firebase_core ^0.4.0.
Thus, if google_sign_in >=5.4.0 and cloud_firestore >=0.11.0 <0.17.0-1.0.nullsafety.0 then firebase_core ^0.4.0.
And because txapita depends on cloud_firestore >=0.11.0 <0.14.0+1, google_sign_in >=5.4.0 requires firebase_core ^0.4.0.
So, because txapita depends on both firebase_core ^2.4.1 and google_sign_in ^5.4.2, version solving failed.
pub get failed (1; So, because txapita depends on both firebase_core ^2.4.1 and google_sign_in ^5.4.2, version solving failed.)
exit code 1
Also, how do I get rid of txapita from the whole project if I can. It seems a lot of the code in the repository needs that package but I can't find the source package.
I've tried changing the versions to the versions in the error message
Here is my pubspec with things I've tried:
If I change the name to the name of the app it adds more errors to the output terminal when I save, is that how I get rid of the packages from the code?
name: txapita
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.2.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
## I've tried doing this with the version numbers
cloud_firestore: ">=0.11.0 <0.14.0+1"
cupertino_icons: null
firebase_auth: null
firebase_core: ^2.4.1
firebase_messaging: ^14.2.1
flutter_google_places: null
flutter_spinkit: ^4.1.2
geocoder: null
geoflutterfire: ^2.0.3+6
geolocator: null
google_maps_flutter: ^2.2.3
google_maps_webservice: null
http: null
location: null
modal_bottom_sheet: ^0.2.2
percent_indicator: ^2.1.7+2
provider: null
rxdart: any
shared_preferences: ^2.0.15
uuid: null
url_launcher: ^5.0.3
get_it: ^1.0.3+2
get: ^4.6.5
share_plus: ^6.3.0
google_sign_in: ^5.4.2
path_provider: ^2.0.11
path_provider_windows: ^2.1.3
shared_preferences_windows: ^2.1.2
path_provider_platform_interface: ^2.0.0
platform: ^3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.1
flutter:
uses-material-design: true
Rather than using null or any find the package version by searching the package.
Link to PUB: https://pub.dev/
E.g. : cloud_firestore: ^4.3.1
Try running flutter pub upgrade --major-versions

Flutter path_provider and connectivity_plus version solving failed

I can't install Flutter's connectivity package due to a version conflicting issue with the path_provider package. I tried exchanging different versions of both packages but no luck. Can anyone please guide me on how to fix this issue here?
Error on Log :
Because connectivity_plus >=1.0.2 depends on connectivity_plus_platform_interface ^1.0.2 which depends on plugin_platform_interface ^2.0.0, connectivity_plus >=1.0.2 requires plugin_platform_interface ^2.0.0.
And because path_provider >=1.6.4 <2.0.0-nullsafety depends on path_provider_platform_interface ^1.0.1 which depends on plugin_platform_interface ^1.0.1, connectivity_plus >=1.0.2 is incompatible with path_provider >=1.6.4 <2.0.0-nullsafety.
So, because cliffjumper depends on both path_provider ^1.6.11 and connectivity_plus ^1.0.5, version solving failed.
pub get failed (1; So, because cliffjumper depends on both path_provider ^1.6.11 and connectivity_plus ^1.0.5, version solving failed.)
In pubspec.yaml file :
enter code version: 1.0.0+1
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: ^0.1.3
rxdart: ^0.26.0
sqflite: ^1.3.1
path_provider: ^1.6.11
http: ^0.12.1
#flutter_facebook_login: ^3.0.0
#google_sign_in: ^4.5.1
flutter_blue: ^0.8.0
google_maps_flutter: ^2.0.5
geolocator: ^6.1.6
device_info: ^2.0.0
shared_preferences: ^0.5.10
crypto: ^3.0.1
uuid: ^3.0.4
latlong: ^0.6.1
geocoder: ^0.2.1
us_states: ^1.0.3
package_info: ^0.4.3+2
weather: ^1.2.4
connectivity_plus: ^1.0.5
try to update all the plugins to their latest version or simply use 'any' keyword instead of version code

Can't install permission_handler and file_picker because of cloud_firestore

I want to get data from Firestore, put it into a list and enable to user to download data on phone in CSV format by using app.
I found two solutions how to export data to CSV file on phone, but both solutions contains packages which I can't install.
Solution #1
How to create and export csv file in flutter?
Dependencies #1
dependencies:
page_view_indicators: ^2.0.0
syncfusion_flutter_xlsio: ^19.1.64-beta
csv: ^5.0.0
ext_storage: ^1.0.3
permission_handler: ^8.0.0+1
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
Problem #1
Because cloud_firestore >=0.13.1 <0.14.0-dev.1 depends on cloud_firestore_platform_interface ^1.0.0 which depends on plugin_platform_interface ^1.0.0, cloud_firestore >=0.13.1 <0.14.0-dev.1 requires plugin_platform_interface ^1.0.0.
And because permission_handler >=8.0.0 depends on permission_handler_platform_interface ^3.5.0 which depends on plugin_platform_interface ^2.0.0, cloud_firestore >=0.13.1 <0.14.0-dev.1 is incompatible with permission_handler >=8.0.0.
So, because gamiforms depends on both permission_handler ^8.0.0+1 and cloud_firestore ^0.13.3, version solving failed.
pub get failed (1; So, because gamiforms depends on both permission_handler ^8.0.0+1 and cloud_firestore ^0.13.3, version solving failed.)
exit code 1
Solution #2
https://medium.com/flutterdevs/exploring-csv-in-flutter-fafc57b02eb1
Dependencies #2
dependencies:
page_view_indicators: ^2.0.0
syncfusion_flutter_xlsio: ^19.1.64-beta
csv: ^5.0.0
ext_storage: ^1.0.3
file_picker: ^3.0.1
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
Problem #2
Because cloud_firestore >=0.13.1 <0.14.0-dev.1 depends on cloud_firestore_platform_interface ^1.0.0 which depends on plugin_platform_interface ^1.0.0, cloud_firestore >=0.13.1 <0.14.0-dev.1 requires plugin_platform_interface ^1.0.0.
And because file_picker >=3.0.0-nullsafety.3 depends on plugin_platform_interface ^2.0.0, cloud_firestore >=0.13.1 <0.14.0-dev.1 is incompatible with file_picker >=3.0.0-nullsafety.3.
So, because gamiforms depends on both file_picker ^3.0.1 and cloud_firestore ^0.13.3, version solving failed.
pub get failed (1; So, because gamiforms depends on both file_picker ^3.0.1 and cloud_firestore ^0.13.3, version solving failed.)
exit code 1
How to fix one of these problems or is there any another way how to export data to phone via app?
I've never done this before and every advice is welcome.
EDIT
dev_dependencies:
flutter_test:
sdk: flutter
cached_network_image: ^2.0.0
cloud_firestore: ^0.13.3
firebase_auth: ^0.15.2
provider: ^3.2.0
#google_sign_in: ^4.1.1
shared_preferences: ^0.5.6+3
random_string: ^2.0.1
In both the cases, you cloud_firestore is way too old. I see that the current version is
cloud_firestore: ^2.2.0
So, unless there is some problem with this version, you should migrate it to the latest version, which should be depending on a later version of plugin_platform_interface
cloud_firestore: ^2.2.0 depends on cloud_firestore_platform_interface: ^5.1.0 which depends on plugin_platform_interface: ^2.0.0.
So, change your pubsec.yaml file to have,
cloud_firestore: ^2.2.0
Then run, flutter pub get.

How to resolve the 3rd party plugin conflicts in Flutter?

This is a part of my pubspec.yaml file
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
http: ^0.13.3
syncfusion_flutter_calendar: ^18.4.47
flutter_chat_bubble: ^1.0.2
intl: ^0.17.0
flutter_local_notifications: ^4.0.1+2
provider: ^5.0.0
sqflite_sqlcipher: ^2.0.0
logging: ^1.0.1
grouped_list: ^3.5.0
visibility_detector: ^0.1.5
smart_select: ^4.3.2
dropdown_search: ^0.5.0
synchronized: ^3.0.0
local_auth: ^1.1.5
font_awesome_flutter: ^9.0.0
lite_rolling_switch: ^0.1.1
flutter_webview_plugin: ^0.3.11
email_validator: ^1.0.6
package_info: ^2.0.0
connectivity: ^3.0.3
device_info: ^2.0.0
encrypt: ^5.0.0
flutter_html: ^1.3.0
url_launcher: ^6.0.2
flutter_inappwebview: ^5.3.2
signalr_core: ^1.1.1
When I try to run the app I get this error
Running "flutter pub get" in mobile_app1...
Because no versions of signalr_core match >1.1.1 <2.0.0 and signalr_core 1.1.1 depends on tuple ^2.0.0, signalr_core ^1.1.1 requires tuple ^2.0.0.
And because no versions of tuple match >2.0.0 <3.0.0 and tuple 2.0.0 depends on quiver ^3.0.0, signalr_core ^1.1.1 requires quiver ^3.0.0.
And because flutter_layout_grid 0.10.5 depends on quiver ^2.0.0 and no versions of flutter_layout_grid match >0.10.5 <0.11.0, signalr_core ^1.1.1 is incompatible with flutter_layout_grid ^0.10.5.
And because flutter_html 1.3.0 depends on flutter_layout_grid ^0.10.5 and no versions of flutter_html match >1.3.0 <2.0.0, signalr_core ^1.1.1 is incompatible with flutter_html ^1.3.0.
So, because mobile_app1 depends on both flutter_html ^1.3.0 and signalr_core ^1.1.1, version solving failed.
pub get failed (1; So, because mobile_app1 depends on both flutter_html ^1.3.0 and signalr_core ^1.1.1, version solving failed.)
I solved this problem by adding this in my pubspec.yaml file
dependency_overrides:
quiver: ^3.0.0
Is there any better way to resolve this conflict?
Set them all toany, then run flutter pub get.
Now you can look in the pubspec.lock file and see what versions you got and put them in pubspec.yaml.

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