Unable to install new packages with pub command - flutter

The following is the excerpt from my pubspec.yaml file. I have added new dependency for shared preferences. when i do command pub get i get the error
Package secondapp requires SDK version >=2.7.0 <3.0.0 but the current SDK is 1.10.1.
I am able to resolve this by adding proper path to my dart installation. But after doing this, the flutter version error is coming.
My yaml file :
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
shared_preferences: ^0.5.6+3
dev_dependencies:
flutter_test:
I am unable to add the dependency. What settings am i missing?

Related

How to add a custom library in project Flutter?

I want to create a custom library and use it in Flutter project.
I created a custom library in project:
But I can't get pub it. (Error)
Because write_library_external depends on lib_math from path which doesn't exist (could not find package lib_math at "..\lib_math"), version solving failed.
pub get failed (66; Because write_library_external depends on lib_math from path which doesn't exist (could not find package lib_math at "..\lib_math"), version solving failed.)
This is my pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
lib_math:
path: /lib_math
# 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:
flutter_test:
sdk: flutter
Please help me! Thanks!
It looks like you added the wrong library path.
With your project, you should try changing the file at pubspec.yaml:
dependencies:
lib_math:
path: ../write_library_external/library/lib_math

rxdart is not installing in my PC due to some issue in dart SDK version

I'm trying to install rxdart by copying it from https://pub.dev/packages/rxdart/versions/0.7.1#-installing-tab- , but its showing some error.
The current Dart SDK version is 2.3.0-dev.0.5.flutter-a1668566e5.
Because flutter_course depends on rxdart >=0.1.0+1 <0.16.0 which requires SDK version >1.12.0 <2.0.0, version solving failed.
pub get failed (1)
exit code 1
I tried using flutter upgrade.
But that doesn't change anything.
My pubsec.yaml file
version: 1.0.0+1
environment:
sdk: ">=2.1.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.2
scoped_model: ^1.0.1
http: ^0.12.0+2
shared_preferences: ^0.5.3+1
rxdart: ^0.7.1
dev_dependencies:
flutter_test:
sdk: flutter

Getting gradle errors in a Flutter application after importing packages

I'm building a Flutter app, and just added the mime and http_parser packages. After that I got the following error when building:
<appname>\build\app\intermediates\merged_manifests\debug\AndroidManifest.xml:35: AAPT: error: resource integer/google_play_services_version (aka com.att.fluttercount:integer/google_play_services_version) not found.
Up until now, the app had built just fine. I backed out my changes, including removing the packages from pubspec.yaml, but the error won't go away.
Here's the relevant part of my pubspec.yaml:
environment:
sdk: ">=2.1.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.2
flutter_map: ^0.5.0+1
scoped_model: ^1.0.1
rxdart: ^0.21.0
flutter_masked_text: ^0.8.0
image_picker: ^0.5.0+9
webview_flutter: ^0.3.6
sqflite: ^1.1.5
http: ^0.12.0+2
#mime: ^0.9.6+2
#http_parser: ^3.1.3
# Must use 'any' as the version of path_provider, because other packages depend on
# earlier versions of path_provider.
path_provider: any
# Note: Must use 'any' as the version of uuid, because some dependencies of flutter_map
# depend on earlier versions of uuid.
uuid: any
dev_dependencies:
flutter_test:
sdk: flutter
Does anyone have any suggestions on how to fix this errror?
I had neglected to mention that I had also removed a dependency on google_maps_flutter, which I was no longer using. I added this dependency back in, and the error went away.

Pubspec.yaml what this file does in Flutter

version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
sqflite: any
path_provider: any
intl: ^0.15.7
# 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:
flutter_test:
sdk: flutter
What things are written in it?
version: 1.0.0+1
The version of your application or package.
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
Your application or package claims to support Dart SDK within this version range
dependencies:
flutter:
sdk: flutter
Your application or package depends on the flutter package which can be found in the SDK
sqflite: any
Your application or package depends on the package sqflite from https://pub.dartlang.org with no specific version constraint.
path_provider: any
intl: ^0.15.7
Your application or package depends on the package intl from https://pub.dartlang.org on any version 0.15.7 or later but before 0.16.0.
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
The ^ changes the meaning for versions 1.0.0 and later.
^0.15.7 means >=0.15.7 <0.16.0
^1.15.7 means >=1.15.7 <2.0.0
because for versions < 1.0.0 breaking changes are indicated by incrementing the middle number, while for >= 1.0.0 breaking changes are indicated by incrementing the first part of the version.
It is responsible for handling of importing images/fonts/third party packages which you want to include in your project.
As explained here on the Flutter site:
The pubspec file manages the assets and dependencies for a Flutter app.
More info can be found here.
To briefly explain, this file written in the YAML language, allows you to manage the pub packages you want to use in your flutter app.
From the dart page :
Every pub package needs some metadata so it can specify its dependencies. Pub packages that are shared with others also need to provide some other information so users can discover them. All of this metadata goes in the package’s pubspec: a file named pubspec.yaml that’s written in the YAML language.
So you will find all the required dependencies / fonts and images sources /sdk version in the pubspec.yaml

Because flutter_tools depends on sockjs_client 0.3.5 which doesn't match any versions,

version solving failed. Error: Unable to 'pub upgrade' flutter tool.
After I forked examples from the Github. I tried to run command "get packages" on VScode. The pub upgrade --force and "flutter doctor" seems not to work anymore. I need help.
pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.1.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.2
rxdart: ^0.18.0
cloud_firestore: ^0.8.2
http: ^0.12.0+1
dev_dependencies:
flutter_test:
sdk: flutter
I can't seem to run flutter command anymore.
I solved the problem by reinstalling the flutter and set the path.