Invalid version constraint: Cannot include other constraints with "^" - dart

I was studying and practicing basics of Flutter and I got this issue.
Code:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2+
english_words: ^3.1.0
I got error after executing command --no-color packages get:
Error on line 21, column 20 of pubspec.yaml: Invalid version constraint: Cannot include other constraints with "^" constraint in "^0.1.2+".
cupertino_icons: ^0.1.2+
^^^^^^^
pub get failed (65)
Development Platform:
Android Studio 3.4 running on Mac OS Mojave

I have ended up coming here after a websearch, the mistake I did was to add a trailing comma
changed this
flutter_audio_recorder: ^0.5.5,
to
flutter_audio_recorder: ^0.5.5

Current stable version of cupertino_icons is 0.1.2
cupertino_icons: ^0.1.2
The caret sign (^) is used for pub dependencies in Dart to indicate a range of version numbers are allowed. Specifically, any version from the specified version up to (but not including) the next non-breaking version is ok.
Remove + sign after 2
Everything before plus is version name and after is version code and you're not specifying any version code, so remove +.

Related

Flutter iOS build failed: Target kernel_snapshot failed: Exception: Errors during snapshot creation: null build failed

The runs fine on Android but when I run it for iOS. It shows a few warnings but also an error. Following are the logs.
Launching lib/main.dart on iPhone SE (2nd generation) in debug mode...
(This is taking an unexpectedly long time.)⡿
Compiler message:
../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/snackbar/snack_route.dart:279:8: Error: The
method 'SnackRoute.install' has more required arguments than those of overridden method 'OverlayRoute.install'.
void install(OverlayEntry insertionPoint) {
^
../../../../desktop/dev/flutter/packages/flutter/lib/src/widgets/routes.dart:41:8: Context: This is the overridden method ('install').
void install() {
^
(This is taking an unexpectedly long time.)⡿../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/routes/default_route.dart:242:9: Error: No named
parameter with the name 'animation'.
animation: animation,
^^^^^^^^^
../../../../desktop/dev/flutter/packages/flutter/lib/src/cupertino/route.dart:435:3: Context: Found this candidate, but the arguments
don't match.
CupertinoFullscreenDialogTransition({
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(This is taking an unexpectedly long time.)⣟../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/snackbar/snack_route.dart:289:18: Error: Too
many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
super.install(insertionPoint);
^
Running pod install... 11.5s
Running Xcode build...
Xcode build done. 63.7s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
/Users/apple/desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.15.1/darwin/Classes/AudioplayersPlugin.m:88:37:
warning: incompatible pointer types sending 'FlutterEngine *' to parameter of type 'NSObject<FlutterBinaryMessenger> * _Nonnull'
[-Wincompatible-pointer-types]
binaryMessenger:_headlessEngine];
^~~~~~~~~~~~~~~
In module 'Flutter' imported from
/Users/apple/desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.15.1/darwin/Classes/AudioplayersPlugin.h:2:
/Users/apple/Desktop/dev/upwork/body_alarm/ios/Flutter/Flutter.framework/Headers/FlutterChannels.h:178:74: note: passing argument
to parameter 'messenger' here
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger;
^
1 warning generated.
/Users/apple/desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/vibration-1.4.0/ios/Classes/VibrationPlugin.m:6:4: warning:
'SwiftVibrationPlugin' is only available on iOS 13.0 or newer [-Wunguarded-availability-new]
[SwiftVibrationPlugin registerWithRegistrar:registrar];
^~~~~~~~~~~~~~~~~~~~
In file included from
/Users/apple/desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/vibration-1.4.0/ios/Classes/VibrationPlugin.m:2:
/Users/apple/Desktop/dev/upwork/body_alarm/build/ios/Debug-iphonesimulator/vibration/vibration.framework/Headers/vibration-Swift.h
:213:12: note: 'SwiftVibrationPlugin' has been marked as being introduced in iOS 13.0 here, but the deployment target is iOS 8.0.0
#interface SwiftVibrationPlugin : NSObject <FlutterPlugin>
^
/Users/apple/desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/vibration-1.4.0/ios/Classes/VibrationPlugin.m:6:4: note:
enclose 'SwiftVibrationPlugin' in an #available check to silence this warning
[SwiftVibrationPlugin registerWithRegistrar:registrar];
^~~~~~~~~~~~~~~~~~~~
1 warning generated.
Compiler message:
../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/snackbar/snack_route.dart:279:8: Error: The
method 'SnackRoute.install' has more required arguments than those of overridden method 'OverlayRoute.install'.
void install(OverlayEntry insertionPoint) {
^
../../../../desktop/dev/flutter/packages/flutter/lib/src/widgets/routes.dart:41:8: Context: This is the overridden method
('install').
void install() {
^
../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/routes/default_route.dart:242:9: Error: No
named parameter with the name 'animation'.
animation: animation,
^^^^^^^^^
../../../../desktop/dev/flutter/packages/flutter/lib/src/cupertino/route.dart:435:3: Context: Found this candidate, but the
arguments don't match.
CupertinoFullscreenDialogTransition({
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/snackbar/snack_route.dart:289:18: Error: Too
many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
super.install(insertionPoint);
^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone SE (2nd generation).
These are the packages I have use in this app:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
json_annotation:
audioplayers: ^0.15.1
wakelock:
shared_preferences:
vibration: ^1.4.0
flutter_local_notifications: ^1.1.5+1
flutter_icons: ^1.0.0+1
flutter_launcher_icons: ^0.7.4
url_launcher: ^5.4.2
get: ^1.15.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
build_runner:
json_serializable:
flutter_test:
sdk: flutter
I have also tried to create a new project and copy all the code from the previous project to new, but still, it does not work. Can anyone help me how to resolve these issues.
Your problem seems to be with the get package. You are a lot of versions behind. Newer versions do not pass a parameter when calling super.install(), which is where your error comes from.
Upgrading to a newer version of the package will probably fix your problem. Unless you have a reason not to go for the newest version, I suggest changing the get: ^1.15.2 line in your pubspec.yaml to get: ^3.2.2 like this :
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
json_annotation:
audioplayers: ^0.15.1
wakelock:
shared_preferences:
vibration: ^1.4.0
flutter_local_notifications: ^1.1.5+1
flutter_icons: ^1.0.0+1
flutter_launcher_icons: ^0.7.4
url_launcher: ^5.4.2
get: ^3.2.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
build_runner:
json_serializable:
flutter_test:
sdk: flutter
While you're at it you might as well have a look at all the other packages you're using as well. Upgrading them to newer version might get rid of some other warning messages as well.

How to add a swagger dependency in pubspec.yaml of flutter

I'm a new developers with flutter, and i want to use "swagger" in my application. I add the dependencies of swagger in pubspec.yaml, but there's always an error.
pubspec.yaml:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.0
swagger: ^1.0.0
when i clicked Packages get, this is the following output:
Running "flutter packages get" in my_first_app...
Because my_first_app depends on swagger ^1.0.0 which doesn't match any versions, version solving failed.
pub get failed (1)
Process finished with exit code 1
How can i use swagger in my Flutter application?
You probably should use instead
open_api: ^2.0.1
swagger is deprecated and not compatible with Dart 2 and the requested version 1.0.0 doesn't exist at all.
From https://pub.dartlang.org/packages/swagger#-readme-tab-

How to fix "pub get failed(1)"

i wanted to build a Flutter App which is using firestore. I implement Firestore and when i am click on "Packages get" this error came.
The current Dart SDK version is 2.1.0-dev.9.4.flutter-f9ebf21297.
Because kegel_app requires SDK version >=1.19.0 <2.0.0-dev.infinity, version solving failed.
pub get failed (1)
How can i fix this? :/
Pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
cloud_firestore: ^0.2.6
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
kegel_app is a dependency
Because kegel_app requires SDK version >=1.19.0 <2.0.0-dev.infinity"
this tells that this package depends on a very old Flutter version that used Dart 1 or Dart 2 pre-releases.
<2.0.0- (with - after the build number) means only Dart versions that are <2.0.0 or == 2.0.0 but pre-releases.
This package is not compatible with recent Flutter versions and needs to be updated.
kegel_app is your project
Change the SDK version constraint in pubspec.yaml to
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"

Flutter: How to resolve Error importing package:http/http.dart

I am very new to Flutter, and stuck at the following error:
package:http/http.dart That library is in a package that is not known.
Maybe you forgot to mention it in your pubspec.yaml file?
Please help in resolving this error.
Go to your pubspec.yaml file , and add the http dependency:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
http: any
Remember, the indentation must be the same as 'flutter' or 'cupertino_icons'
And don't forget to run this command in your terminal :
flutter packages get
I had the same problem. You just have to add latest http dependencies in pubspec.yaml
Here is the full code,
dependencies:
flutter:
sdk: flutter
http: ^0.12.0+1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
Don't forget to change verson no. of http
To check latest version of http click here
If you are running app directly from command line then you could also do:
with Flutter:
$ flutter packages get
with pub:
$ pub get
I've found that, when in VS Code, you might need to restart the editor to get it to see the new http module that 'pub get' pulled in. You can have your .dart code and pubspec.yaml exactly right but you still get the compiler/lint error.
You need to import like this:
import 'package:http/http.dart' as http;
add below to pubspec.ymel file
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
http: ^0.12.0+1
use flutter pub to find the latest version
call
flutter packages get
1.Install http package
flutter pub add http
2.check pubspec.yaml file
dependencies:
http: ^0.13.4
3.Import in file
import 'package:http/http.dart';
Reference
just got to pubspec.yaml file and tweak some changes in file
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
http:
under dependencies section just add http like in code description .
flutter will automatically resolve it and will add updated version of http .
You have to add the http dependency in the pubspec.yaml file as shown below:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
http: ^0.12.0+2
Please take note of the indentation. After doing the above, run the below command in your terminal:
flutter packages get
As at the time of writing this, the latest http version is 0.12.0+2. You can learn more by visiting this link.
this worked for me:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
http: any
then:
flutter doctor -v
Finally:
flutter packages get
1. Add this to your package's pubspec.yaml file:
dependencies:
http: ^0.12.1
2. install it :
$ flutter pub get
3. Now in your Dart code, you can use:
import 'package:http/http.dart' as http;
Add below to pubspec.yaml file
dependencies:
http: ^0.12.0+1
Or Just add http
dependencies:
http:
flutter will automatically used latest version of http .
Then use pub get
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
http: ^0.12.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- images/
try to update the sdk versions and then pub get or flutter pub get to get the packages get install
just add in pubspec.yaml
http: ^0.12.0+2
like as
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
http: ^0.12.0+2
and run in terminal
flutter pub get
finally add in class
import 'package:http/http.dart' as http;
When I got this issue, I just close the project from Android Studio (File -> Close Project). And then open it again.
That works for me.
Simply just Restart the project.
But Make sure to add the certain dependency to the pubspec.yaml file and do pub get.
-Just run this below command in your project directory to install http module
flutter pub add http
You first find 'dependencies:' in pubspec.yaml
then under 'dependencies:' type http: ^0.12.0+2 and then press ctrl + s to run get packages.
sample:
dependencies:
http: ^0.12.0+2
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.2
cupertino_icons: ^0.1.2
http: any
http:
have to be align with the other dependencies.
I had the same issue although I had the latest http package in Pubspec.yaml file. This error was still in there I did these 2 steps and error was resolved.
Remove import 'dart:_http'; if it is there
Add import 'dart:convert';

Error after running "flutter upgrade"

I am getting the following error after running flutter upgrade:
Because every version of flutter_test from sdk depends on path 1.5.1 and flutter_advanced_networkimage >=0.2.9+1 depends on path ^1.6.0, flutter_test from sdk is incompatible with flutter_advanced_networkimage >=0.2.9+1.
So, because testapp depends on both flutter_advanced_networkimage ^0.2.10 and flutter_test any from sdk, version solving failed.
pub upgrade failed (1)
My pubspec.yaml:
name: testapp
description: A new Flutter application.
dependencies:
flutter:
sdk: flutter
device_info: "^0.2.0"
shared_preferences: "^0.4.1"
flutter_parallax: "^0.1.1"
cached_network_image: "^0.4.1"
connectivity: "^0.3.1"
chewie: "^0.6.0"
flutter_statusbarcolor: "^0.0.3"
fluro: "^1.3.1"
carousel_slider: "^0.0.4"
flutter_advanced_networkimage: "^0.2.10"
flutter_sticky_header: "^0.3.0"
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
I'm trying to get it working for hours, please help
I assume you are using the beta channel.
I think this doesn't happen in dev channel.
To switch to the dev channel run in a command line shell
flutter channel dev
flutter doctor
and try again.
I've had similar problems. My problem like this:
Because every version of flutter_test from sdk depends on http 0.12.0
and flutter_cache_manager 0.1.2 depends on http ^0.11.3+14,
flutter_test from sdk is incompatible with flutter_cache_manager
0.1.2. And because no versions of flutter_cache_manager match >0.1.2 <0.2.0, flutter_test from sdk is incompatible with
flutter_cache_manager ^0.1.2.
Here's how I solved it:
dependencies:
...
dependency_overrides:
http: ^0.12.0
so, I thank you can try it:
dependencies:
...
dependency_overrides:
path: ^1.6.0

Resources