During the installation fo mongo_dart 0.4.3 I received the following error (pub get)
Because every version of flutter_test from sdk depends on crypto 2.1.4 and mongo_dart >=0.4.1-dev.2.2 depends on crypto ^2.1.5, flutter_test from sdk is incompatible with mongo_dart >=0.4.1-dev.2.2.
So, because fluttermongo depends on both mongo_dart ^0.4.3 and flutter_test any from sdk, version solving failed.
pub get failed (1; So, because fluttermongo depends on both mongo_dart ^0.4.3 and flutter_test any from sdk, version solving failed.)
Process finished with exit code 1
my pubspec.yaml:
name: fluttermongo
description: A new 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:
mongo_dart: ^0.4.3
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
dependency_overrides:
path: 1.6.4
flutter:
uses-material-design: true
What am I missing ? how can I sove it ?
from
flutter_test from sdk depends on crypto 2.1.4 and mongo_dart >=0.4.1-dev.2.2 depends on crypto ^2.1.5,
downgrade your fluttermongo version. check to see that it supports crypto 2.1.4
Related
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)
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
I've been getting an error ever since I tried adding integration_test package along with get_test and it's primarily due to the fact that just_audio depends on crypto: ^3.0.0 while integration_test depends on crypto: ^2.1.5.
I tried to look online to see if it's possible to only install dependencies without dev_dependencies however it seems like flutter pub cli tool doesn't support that yet based on this issue.
Here is my pubspec.yaml
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
share: ^2.0.1
get:
get_storage:
shared_preferences: ^2.0.5
audio_service: 0.17.0-nullsafety.0
just_audio: ^0.7.4
dev_dependencies:
flutter_test:
sdk: flutter
get_test: ^3.13.3
integration_test: ^1.0.2+1
test: ^1.14.4
This is the error I am getting.
Because every version of integration_test depends on flutter_driver any from sdk which depends on crypto 2.1.5, every version of integration_test requires crypto 2.1.5.
And because just_audio 0.7.4 depends on crypto ^3.0.0 and no versions of just_audio match >0.7.4 <0.8.0, integration_test is incompatible with just_audio ^0.7.4.
So, because egy_fm_radio depends on both just_audio ^0.7.4 and integration_test ^1.0.2+1, version solving failed.
pub get failed (1; So, because egy_fm_radio depends on both just_audio ^0.7.4 and integration_test ^1.0.2+1, version solving failed.)
I think this specific issue could have been be resolved by updating the Flutter SDK to the latest (>=2.2.0), but if there's anybody experiencing a similar issue, consider using Dependency overrides to override dependencies of built-in packages such as integration_test and flutter_driver.
dependency_overrides:
crypto: ^3.0.0
Note that this involves some risk and pub will show you a warning during dependency resolution.
Looking through your pubspec.yaml it appears the problem lies within the crypto dependency mismatch.
Inside your pubspec.yaml you can explictly declare the latest crypto version:
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
share: ^2.0.1
crypto: 3.0.1
get:
get_storage:
shared_preferences: ^2.0.5
audio_service: 0.17.0-nullsafety.0
just_audio: ^0.7.4
dev_dependencies:
flutter_test:
sdk: flutter
get_test: ^3.13.3
integration_test: ^1.0.2+1
test: ^1.14.4
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.So, it creates an error incase of mismatch because you cannot have two different versions of the same package.
I need to add flutter_localizations package to use Arabic language in my application, but when I add it in pubspec.yaml, it gives me the following error:
Because calendar_timeline >=0.6.1 depends on intl ^0.16.1 and every version of flutter_localizations from sdk depends on intl 0.17.0-nullsafety.2, calendar_timeline >=0.6.1 is incompatible with flutter_localizations from sdk.
So, because elderly_app depends on both flutter_localizations any from sdk and calendar_timeline ^0.7.0, version solving failed.
pub get failed (1; So, because elderly_app depends on both flutter_localizations any from sdk and calendar_timeline ^0.7.0, version solving failed.)
This is my pubspec.yaml:
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
cupertino_icons: ^1.0.1
calendar_timeline: ^0.7.0
flutter_datetime_picker: ^1.5.0
date_picker_timeline: ^1.2.1
hijri: ^2.0.3
flutter_week_view: ^1.0.0+2
url_launcher: ^5.7.10
It works when I delete the lines under flutter_localizations like cupertino_icons and calendar_timeline
According to the above message you should decrease your calendar_timeline version to lower than 0.6.1. for example calendar_timeline: 0.6.0
and add this line to pubspec.yaml file:
dependency_overrides:
intl: ^0.16.0
Try updating all of your packages to the latest version.
Error:
Because
built_value_generator >=8.0.0-nullsafety.0 depends on built_value ^8.0.0-nullsafety.0
flutter_app depends on built_value ^7.1.0, built_value_generator >=8.0.0-nullsafety.0 is forbidden.
So, because flutter_app depends on built_value_generator ^8.0.0-nullsafety.0, version solving failed.
pub get failed (1; So, because flutter_app depends on built_value_generator ^8.0.0-nullsafety.0, version solving failed.)
If I delete the following, then the app compiles with no issues.
built_value_generator: ^8.0.0-nullsafety.0
My dependencies are below
version: 1.0.0+1
environment: sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
chopper: ^2.4.1
provider: ^3.0.0+1
connectivity: ^0.4.3+2
built_value: ^7.1.0
cupertino_icons: ^1.0.1
dev_dependencies:
flutter_test:
sdk: flutter
chopper_generator: ^2.3.4
built_value_generator: ^8.0.0-nullsafety.0
build_runner:
flutter:
uses-material-design: true
The problem is in deppendency versions mismatching, it is obviously described in warning message. So don't use nullsafety version of built_value_generator, use latest non-nullsafety version. Or use nullsafety version of built_value.
Also it is recommended to read about dart dependencies https://dart.dev/tools/pub/dependencies.
It is also recommended to set minimum version of dart SDK to 2.7 not.2.1.
You can use the 'any' to resolve the issue
built_value_generator: any