Dependency conflict - flutter

I am little bit confused. When I added easy_localization dependency and run flutter pub get then I give following message:
Because easy_localization >=2.1.0+1 <2.3.4-nullsafety depends on flutter_localizations
any from sdk which depends on path 1.8.0-nullsafety.1,
easy_localization >=2.1.0+1 <2.3.4-nullsafety requires path 1.8.0-nullsafety.1.
I switched to Stable channel of Flutter and I have following Dart version:
Flutter 1.22.6
Dart 2.10.5
Here is my fully pubspec file:
name: demo
description: demo
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: 1.0.0
flutter_bloc: 6.1.1
equatable: 1.2.5
easy_localization: 2.3.3+1
dependency_overrides:
intl: 0.16.1
flutter:
uses-material-design: true
assets:
- assets/translations/
I don't understand why I have dependency conflict. Also I tried remove .lock files. Do you have any ideas where is a problem? Thanks.

Its simple, Just remove dependency version like this
image_picker:
intl:
http: ^0.12.2
It will automatic choose version which is needed

Related

Flutter - "flutter from sdk and syncfusion_flutter_datagrid ^19.1.65-beta, version solving failed." Error

I am getting an error like this:
Because every version of flutter from sdk depends on collection 1.16.0 and syncfusion_flutter_datagrid >=19.1.54-beta <20.1.48 depends on collection >=1.9.0 <=1.15.0, flutter from sdk is incompatible with syncfusion_flutter_datagrid >=19.1.54-beta <20.1.48.
So, because datagrid_json_datasource depends on both flutter from sdk and syncfusion_flutter_datagrid ^19.1.65-beta, version solving failed.
pubspec.yaml:
name: datagrid_json_datasource
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
http: ^0.12.0
flutter:
sdk: flutter
intl: ^0.17.0
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
syncfusion_flutter_datagrid: ^19.1.65-beta
flutter:
uses-material-design: true
i try too chenge sdk version when i change to sdk version and also try flutter clean and flutter pub get.
Try updating to newer version of syncfusion_flutter_datagrid.
Add to pubspec.yaml:
dependencies:
syncfusion_flutter_datagrid: ^20.3.52
Then run flutter pub get
I tested this with multiple Flutter versions and the one you should use is the 2.2.0 because this is the version which contains the Collector 1.9.0, you cannot use another version of Collector or override it because dart:Collector contains different data structures that are used in the code base of flutter.
This is the pubspec.yaml that works for me for Flutter 2.2.0
Hope it helps you :)
name: test_datasourcee
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
syncfusion_flutter_datagrid: ^19.1.65-beta
flutter:
uses-material-design: true

Why does Flutter shared_preferences download an older version without null safety?

I'm trying to add shared_preferences to a Flutter project. By default, version 0.5.7+3 is downloaded which isn't null safe.
Adding the latest version, 2.0.15, gets the following error:
Running "flutter pub get" in platform...
Because shared_preferences >=2.0.10 depends on shared_preferences_windows ^2.0.1 which depends on path_provider_platform_interface ^2.0.0, shared_preferences >=2.0.10 requires path_provider_platform_interface ^2.0.0.
And because path_provider_platform_interface >=2.0.0 depends on platform ^3.0.0, shared_preferences >=2.0.10 requires platform ^3.0.0.
So, because platform depends on shared_preferences ^2.0.15 and platform is 1.0.0+1, version solving failed.
pub get failed (1; So, because platform depends on shared_preferences ^2.0.15 and platform is 1.0.0+1, version solving failed.)
exit code 1
The platform version is actually the version number in the pubspec.yaml. Changing the version number to 3.0.0 downloads 2.0.15 of shared_preferences but then fails on running:
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
lib/main.dart:1
Building with Flutter multidex support enabled.
: Error: Error when reading 'lib/platform.dart': No such file or directory
../…/src/method_channel_path_provider.dart:7
import 'package:platform/platform.dart';
^
: Error: Error when reading 'lib/platform.dart': No such file or directory
../…/interface/common.dart:8
import 'package:platform/platform.dart';
pubspec.yaml is:
name: platform
description: A new Flutter project.
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.3.3'
dependencies:
flutter:
sdk: flutter
firebase_core:
firebase_auth:
google_sign_in:
firebase_analytics:
font_awesome_flutter:
provider:
shared_preferences:
config:
path: config
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
assets:
- assets/images/
uses-material-design: true
How can I add a null safe version of shared_preferences to my project?
Why is the pubspec.yaml version number being read as platform version?
The problem turned out to be the platform name in the pubspec.yaml.
This pubspec.yaml
name: platform
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=2.18.2 <3.0.0'
dependencies:
shared_preferences:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
resolves to version 0.5.7+3 of shared_preferences:
Package Name Current Upgradable Resolvable Latest
direct dependencies:
shared_preferences *0.5.7+3 *0.5.7+3 *0.5.7+3 2.0.15
Changing the pubspec.yaml name field to something different:
name: notplatform
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=2.18.2 <3.0.0'
dependencies:
shared_preferences:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
means shared_preferences is updated when flutter pub upgrade is run
shared_preferences 2.0.15 (was 0.5.7+3)

How do i upgrade my current flutter project to its latest dependencies packages and latest version of flutter?

I have cloned an old flutter project and need to update it's dependencies and version of flutter. What are the steps needed to do this correctly from what i have gathered in the terminal i would run in this order the following commands:
flutter upgrade
dart migrate
flutter pub upgrade --major-versions
dart migrate
i will include my pubspec.yaml:
pubspec.yaml
name: vtc_sentry_fl
description: A new Flutter project.
version: 0.2.1+5
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
cupertino_icons: ^0.1.3
http: ^0.12.1
shared_preferences: ^0.5.7+3
flag: ^1.0.0
auto_size_text: ^2.1.0
firebase_messaging: ^6.0.15
date_range_picker: ^1.0.6
intl: ^0.16.0
flutter_launcher_icons: ^0.7.4
fl_chart: ^0.9.4
flutter_icons:
android: true
ios: true
image_path: "assets/images/vt_icon_logo.png"
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
fonts:
- family: Montserrat
fonts:
- asset: assets/fonts/Montserrat-Medium.ttf
- asset: assets/fonts/Montserrat-Light.ttf
- asset: assets/fonts/Montserrat-Bold.ttf
assets:
- assets/images/
To upgrade Flutter run flutter upgrade and adjust the SDK version as mentioned by Kartik Patel.
However, in order to upgrade the project's dependencies you have to be careful. I suggest you check out the website of each dependency on pub.dev and read the change logs. Newer versions might introduce breaking changes.
You can run flutter pub outdated to list outdated packages and even show their transitive dependencies, you can then update the version of the packages in pubspec.yaml and run flutter pub upgrade to perform the upgrade.
run flutter upgrade command to update flutter and flutter pub upgrade to update all dependencies from pubspec.yaml file, and use latest sdk version in pubspec.yaml file:
environment:
sdk: ">=2.12.0 <3.0.0"

How to solve multi dependency version conflicts simply?

I have imported a project in android studio flutter. But, there is an incredible amount of version conflict coming in. If one solves other rises and if that goes down, other one rises. I am trying to get all packages and it is showing me the following error as below.
Because date_utils >=0.1.0+3 depends on intl ^0.16.0 and prokit_flutter depends on intl 0.17.0-nullsafety.2, date_utils >=0.1.0+3 is forbidden.
So, because prokit_flutter depends on date_utils ^0.1.0+3, version solving failed.
pub get failed (1; So, because prokit_flutter depends on date_utils ^0.1.0+3, version solving failed.)
Process finished with exit code 1
And my pubspec.yaml code is as below.
name: prokit_flutter
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.6.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
url_launcher: 5.0.3
nb_utils: 3.1.6+7
google_fonts: 1.1.0
animations: 1.1.2
intl: 0.17.0-nullsafety.2
http: 0.12.2
firebase_core: 0.5.0
firebase_analytics: 6.0.0
firebase_crashlytics: 0.1.4+1
google_sign_in: 4.5.3
html: 0.14.0+3
share: 0.6.5
mobx: ^1.2.1+2
flutter_mobx: ^1.1.0+2
flutter_statusbarcolor: 0.2.3
simple_animations: 1.3.8
snaplist: 0.1.8
flutter_svg: 0.18.1
flutter_slidable: 0.5.7
flutter_staggered_grid_view: 0.3.2
flutter_staggered_animations: 0.1.2
geolocator: 5.3.2+2
geocoder: 0.2.1
google_maps_flutter: 0.5.21+3
clustering_google_maps: 0.1.2
razorpay_flutter: 1.2.2
signature: 3.2.0
liquid_swipe: 1.5.0
lipsum: 1.0.1
flutter_colorpicker: 0.3.4
clippy_flutter: 1.1.1
flutter_tags: ^0.4.8
image_picker_gallery_camera: 0.1.6
video_player: 0.10.11+2
charts_flutter: ^0.9.0
like_button: ^1.0.1
flutter_reaction_button: ^1.0.1
lottie: ^0.6.0
showcaseview: ^0.1.6
date_utils: ^0.1.0+3
cached_network_image: ^2.3.1
flutter_localizations:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
mobx_codegen:
build_runner: ^1.9.0
#flutter packages pub run build_runner build
flutter:
uses-material-design: true
assets:
- images/smartDeck/images/
fonts:
- family: Andina
fonts:
- asset: fonts/andina.ttf
And there are 4-5 dependency version error. How can I solve this version error thing in one click or I can just somehow skip this version problem and get the thing done. Please help, Thanks in Advance.
Whenever conflicts between dependencies occur, the simplest solution is to just remove the version number of both that dependencies and type 'any' without quotes in front of them.
for example let's say this following two dependency conflicts:
shared_preferences: ^0.5.7+3
requests: ^3.3.0
then do following:
shared_preferences: any
requests: any
After this do pub get and issue will be resolved. Now, most importantly, don't leave any dependency on this form. instead goto pubspec.lock file and search these two dependencies. Flutter itself chooses the versions that don't conflict, copy those and replace it to pubsec.yaml
You can use dependency_overrides in your pubspec.yaml to force a specific package version. The package version will override any reference to a dependency in the entire app.
In your case you could use
dependencies:
flutter:
sdk: flutter
...
cupertino_icons: ^1.0.0
dependency_overrides:
intl: ^0.17.0-nullsafety.2
See dependency_overrides for more information.
Replace intl: 0.17.0-nullsafety.2 version with intl: 0.16.1 and remove intl from dependency overrides.
Now, run pub get command.
You can simply change the version of package that is causing conflic with another version which is compatible with your dart SDK. I tried it and the problem was solved.
had the same problem; ran the following command:
flutter pub upgrade --major-versions
if you don't mind having the latest version of all the dependencies while solving version conflict issues, this should be a quick fix.
I had this problem after resetting my Mac mini.
If you still have the pubspec.lock file at the last successful run (or get it from another dev, on that dev's computer the project is still running).
flutter clean.
Replace pubspec.lock by the old one.
Run the project again.

Not able to install dependencies in my flutter project

I am trying to install image_picker and firbase_storage in my flutter project. But whatever version I try to install, it fails. and gives error like this -
Because image_picker >=0.3.0 requires Flutter SDK version >=0.1.4 <2.0.0 and image_picker <0.3.0 requires SDK version >=1.8.0 <2.0.0, image_picker is forbidden.
I have tried out installing every version but not able to install even a single version.
Flutter doctor -v is working fine and following is the content of my pubspec.yaml file
name: timepass
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter_secure_storage: ^3.1.3
image_picker: ^0.1.4
firebase_storage: ^0.2.0
location: ^1.4.1
graphql_flutter: ^0.9.1
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
One way to approach this kind of dependency issues is that just let the pub to fetch the appropriate version if you are facing any issues or conflicts with dependency.
Add the dependency on pubspec.yaml as below
dependencies:
image_picker: any
or
dependencies:
image_picker:
Then check the pubspec.lock file and find the version number.
In this case, you may get
image_picker:
dependency: "direct main"
description:
name: image_picker
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0"
Then you can modify pubspec.yaml as
dependencies:
image_picker: ^0.5.0
You need to allow a newer image_picker version.
Try
dependencies:
image_picker:
or
dependencies:
image_picker: ^0.5.0