Can someone help me? Why can't I add this package to my pubspec.yaml?
I assume your project name is also integration_test
, change the name of your project as when running the pub get command, flutter reads the project name instead of the library name.
Add the dependencies to the dev_dependencies section of the app’s pubspec.yaml file, specifying the Flutter SDK as the location of the package.
dev_dependencies:
integration_test:
sdk: flutter
flutter_test:
sdk: flutter
More documentation on here with example.
Related
I am getting error while compiling flutter app
Anyone can help?
Here is full error :
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/carousel_slider-4.2.0/lib/carousel_slider.dart:311:29: Error: Member not found: 'trackpad'.
PointerDeviceKind.trackpad
Here are dependencies from yaml file
`
version: 1.0.0+1
environment:
sdk: ">=2.16.2 <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: ^1.0.2
carousel_slider: ^4.2.0
video_player:
`
Welcome Rohan!
This issue is because of the introduction of the new trackpad gestures in version 3.3.0-0.0.pre of flutter as documented here: https://docs.flutter.dev/release/breaking-changes/trackpad-gestures looks like carousel_slider has been update to use it.
You have two options:
Upgrade your flutter SDK to 3.3.0-0.0.pre or greater
Or downgrade carousel_slider: 4.1.0
Clean pub cache folder by command bellow
flutter pub cache repair
And download all dependencies by following command in your project directory
flutter pub cache repair
IMPORTANT
All libraries will be downloaded from the internet from the scratch and this will take some time depends how many libraries are you using
you should declare carousel_slider: 4.1.1 in pubspec.yaml
instead of carousel_slider: ^4.1.1 because with ^ sign flutter will try to use latest version in pub.dev
Seems if a plugin package is included in pubspec.yaml, it will be included in build even not use.
Take my sample project https://github.com/J-Siu/flutter_scroll as example, pubspec.yaml
name: flutter_scroll
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.17.6 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
google_sign_in: ^5.4.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
google_sign_in is a plugin but not imported in any of the source code and there is no dependency using it.
However if you go to the demo page: https://j-siu.github.io/app/flutter_scroll/#/ , open browser inspector -> network, reload the page, you will see https://apis.google.com/js/platform.js is loaded. That is done by google_sign_in initialization.
Question: Other than removing it from pubspec.yaml, is there a way to exclude plugin from final build if it is not imported in source and other dependency?
PS: You can experiment with a plain starting project:
flutter create --platforms web my_testing
cd my_testing
flutter pub add google_sign_in
flutter run (should open chrome)
check inspector -> network with reload
No, i dont think its possible to not use a package thats defined in pubspec during build. You could take a look at packages like
Dependency validator
Where you get to know which packages arent used at all and remove them easily.
I need to get the latest version(just number, not a package) of a certain package hosted on pub.dev from the command line.
Something like npm view url-loader version from npm.
Can not find any analogues so far.
I'm creating a script that automatically changes the version in pubspec.yaml to the latest+1 and publishes the package. The only option i have found so far is to download the html contents of the package web page on pub.dev and search for the version there which does not seem to be very consistent.
Simply let the version in pubspec.yml blank. like:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
cupertino_icons:
We are working on Flutter v1.7.8+hotfix.4, using VS Code added a new package called english_words. the package is updated with all required files in the app but SDK, not updated flutter/packages, here we are unable to see the package folder.
Due to the above issues getting an error from main.dart file
Target of URI doesn't exist 'package:english_words/english_words.dart'.
pubspec.yaml
dependencies:
flutter_test:
sdk: flutter
english_words: ^3.1.5
run flutter packages get got response exit code 0
run flutter pub get or pub get no error.
reload/rebuild the app using flutter run but packages not updated.
pubspec.yaml, pubspec.lock, .packages updated fine.
tried from VS Code Tool click get Packages not solved.
Check if you have this in your pubsec.yaml file
dependencies:
flutter:
sdk: flutter
english_words: ^3.1.5
In you code there is dev_dependencies. Replace this dependency
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