Flutter: packages not added into flutter SDK - flutter

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

Related

i have a problem in my flutter App when project run in android studio

** flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/firebase_app.dart:18:25: Error: Member not found: 'FirebaseAppPlatform.verifyExtends'.
FirebaseAppPlatform.verifyExtends(_delegate);
I used
.
.
.
firebase_core: ^1.7.0....I cheked in my code but there is not show any error shoud i change in my library file of firebase_core:1.24.0 ***
I have encountered the same issue and i fixed by:
Updating the packages in pubspec.yaml file to the latest versions:
firebase_core: ^2.1.1
firebase_auth: ^4.1.0
cloud_firestore: ^4.0.3
Removing the pubspec.lock file
Running flutter clean
And last running this command flutter pub get
Because there are some breaking change of firebase_core_platform_interface that do not comply with semantic versioning: https://github.com/firebase/flutterfire/issues/9806
You need to overwrite this library:enter image description here

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 pub get info about a package from command line

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: