Flutter pub get info about a package from command line - flutter

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:

Related

Getting error in flutter compilation like : carousel_slider-4.2.0/lib/carousel_slider.dart:311:29: Error: Member not found: 'trackpad'

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

Error when running flutter pub run build_runner build --delete-conflicting-outputs

I'm trying to integrate a smart contract into my flutter and I'm referring to this example. I have included all the dependencies and dev_dependencies in the first step and I'm stuck in the second step where this error occurs where the system could not find the path to builders.dart in the web3dart package.
After updating Flutter to version 2.5.2, there were some conflicts even though no code was changed, therefore I use any in pubspec.yaml.
dependencies:
flutter:
sdk: flutter
moor: ^4.5.0
provider: ^5.0.0
path_provider: any
path: ^1.8.0
dev_dependencies:
flutter_test:
sdk: flutter
moor_generator: any
build_runner: any
flutter_launcher_icons: any
For me, I had to downgrade to web3dart: ^2.3.5 from ^2.4.1 (pubspec.yaml)
Ran flutter pub get
But the web3dart-2.4.1 folder remained in .../flutter/.pub-cache/hosted/pub.dartlang.org/
The problem was that build_runner was still looking in the 2.4.1 folder
So I removed everything from the .../flutter/.pub-cache/hosted/pub.dartlang.org/web3dart-2.4.1 folder and moved everything from the .../flutter/.pub-cache/hosted/pub.dartlang.org/web3dart-2.3.5 folder into the .../flutter/.pub-cache/hosted/pub.dartlang.org/web3dart-2.4.1 folder
Closed Android Studio
Reopened it and ran flutter pub run build_runner build
And it worked
CAUTION: DO NOT RUN FLUTTER PUB UPDATE BEFORE RUNNING FLUTTER PUB RUN BUILD_RUNNER BUILD
When I ran flutter pub update, it pulled a completed different web3dart version (2.4.0) into .../pub.dartlang.org/, which has the same bug in it.
Your folder version may be different, but if you can get the web3dart-2.3.5 version and find which folder build_runner is looking in (by running it in Terminal and reading the error message), you can put the good code into there and it should work

Can we stop Flutter plugin loading if not use in final build

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.

Can't add integration_test package

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.

Flutter: packages not added into flutter SDK

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