how to update flutterfire_web_sdk_version and how to enable 'non-nullable' language feature - flutter

When I run my code, then I get this warning:
Flutter Web Bootstrap: Programmatic
WARNING: FlutterFire for Web is explicitly tested against Firebase JS SDK version "8.10.1"
but you are currently specifying "8.6.1" by either the imported Firebase JS SDKs in your web/index.html
file or by providing an override - this may lead to unexpected issues in your application. It is recommended that you change all of the versions of the
Firebase JS SDK version "8.10.1":
If you override the version manually:
change:
<script>window.flutterfire_web_sdk_version = '8.6.1';</script>
to:
<script>window.flutterfire_web_sdk_version = '8.10.1';</script>
If you import the Firebase scripts in index.html, instead allow FlutterFire to manage this for you by removing
any Firebase scripts in your web/index.html file:
e.g. remove: <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script>
I already tried to find the <script>window.flutterfire_web_sdk_version = '8.6.1';</script> in the index file, but I can't find it. Therefore I couldn't upgrade it.
Does someone know how to fix this warning?
second question:
When I want to use non-nullable, then I get this error:
This requires the 'non-nullable' language feature to be enabled.
I am using sdk: '>=2.6.0 <3.0.0' so it should actually be enabled. Does someone know why it isn't working/enabled?
packages that i am using are (maybe this helps you):
cupertino_icons: ^1.0.2
responsive_builder: ^0.4.2
get_it: ^7.2.0
provider: ^4.1.1
provider_architecture: ^1.1.1+1
firebase_auth: ^3.3.19
firebase_core: ^1.17.1
cloud_firestore: ^3.1.13
I already tried to clean flutter and using Pug get again.

Second question:
For null safety you need to use sdk: '>=2.12.0 <3.0.0'. Here you can find how to enable null safety.

Related

How to set dependencies in the right way in pubspec.yaml in Flutter

Here are a few dependency examples from my pubspec.yaml file in my Flutter project.
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.14.4
firebase_core_web: ^0.2.1
firebase_crashlytics: "^0.2.4"
firebase_analytics: "^6.3.0"
I just followed installation guidelines when installing each of them. As seen, some dependencies have the version number in "..." while others don't.
It seems to be working in both ways but I wonder what the right way of doing it. Should I always put the version number into "..." ?
The best way to do this is:
flutter pub add form_field_validator
where "form_field_validator" is the name of dependency
Have a look why it is a best method:
It automatically adjusts all of the the dependencies
So you don't get "version solving failed" error like this showing below:
Because flutter_bloc: 0.21.0 depends on provider: ^3.0.0 and no versions of flutter_bloc match: >0.21.0 <0.22.0, flutter_bloc: ^0.21.0 requires provider: ^3.0.0. So, because it tells_me that it depends on both provider: ^4.1.2 and flutter_bloc: ^0.21.0, version solving failed.
https://pub.dev/packages/form_field_validator/install
has both methods copy and paste the given command in your project directory
See below image:
Thank you I hope it clears everything, happy coding!
You can provide version numbers with and without quotes. The quotes are used for providing range constraints on dependencies like this:
dependencies:
url_launcher: '>=5.4.0 <6.0.0'
So that's why both options work. If you are not using ranges you can omit the quotes but it comes down to personal/team preference. See the Flutter documentation for more information on using packages.
If you don't put any number or version number, it takes the latest version.
When creating new projects, it will work good. However if you are re-using codes from other projects, you might want to use the exact same version of the dependencies, hence you define them.

How to resolve Firebase AdMob Integration problem

I am trying to add AdMob ads to my Flutter app. For that, I tried using firebase_admob (^0.9.3+2) plugin but it's not working for me, it stuck at build.apk.
I am getting the output as :
Note: /home/abhishek/dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_admob-0.9.3+2/android/src/main/java/io/flutter/plugins/firebaseadmob/AdRequestBuilderFactory.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
My dependency in pubspec.yml are :
dependencies:
flutter:
sdk: flutter
meta: ^1.1.8
platform: ^2.2.1
firebase_core: ^0.4.0+9
firebase_analytics: ^5.0.2
firebase_admob: ^0.9.3+2
Where am I doing wrong?
See if you can remove firebase_core: ^0.4.0+9 then exec flutter clean
Not sure if it is related or not, but I'm having problems adding dependencies:
Error: Could not resolve the package 'google_sign_in' in 'package:google_sign_in/google_sign_in.dart'.
lib/authsvc.dart:7:8: Error: Not found: 'package:google_sign_in/google_sign_in.dart'
import 'package:google_sign_in/google_sign_in.dart';
I'm able to add the dependency in the pubspec.yaml file, run 'pub get' and it says that it downloads fine. No errors are reported in the editor (i.e. it recognizes the new commands and doesn't flag them). However, when I try to compile/build it, I get the above error message. 'Pub get' worked fine until I upgraded to the latest version of Flutter (v. 1.17.3) before I believe I was on (v. 1.17.0).
To fix it, I hardcoded the path in the Dart_Packages.xml file.
(I'm not looking to troubleshoot further, just adding this in case it helps the developers identify the problem). Thanks!

Because every version of flutter_test from sdk depends on... flutter_test from sdk is forbidden, version solving failed

I'm having this issue when I've added http dependency in my flutter project. Can anyone please help me with it?
If you get the message:
Because every version of flutter_test from sdk depends on...
It means flutter_test depends on a dependency with version lower than you specified in another dependency.
To solve this, open pubspec.yaml, and remove the version number of the problem dependency:
Example:
Change
archive: ^2.0.13 --> remove this number
To:
archive:
You have provided or trying to use http: ^0.12.0 dependency on implementing API calls in pubspec.yaml file but flutter_test will require http: ^0.11.3+17. That's why it fails. Please replace
dependencies:
flutter:
sdk: flutter
http: ^0.12.0
with
dependencies:
flutter:
sdk: flutter
http: ^0.11.3
Hope it will help you out.
In my case, I somehow deleted sdk: flutter:
dependencies:
flutter:
sdk: flutter
I was facing a similar error. I solved it by removing all the version numbers from the dependencies: section in pubspec.yaml.
So, if my pubspec.yaml looked like this before:
dependencies:
freezed_annotation: ^0.14.3
I changed it to this:
dependencies:
freezed_annotation:
I'm assuming this fetches the latest "possible" version of each package.
Can you please provide the dependencies in your pubspec.yaml? It looks like your app depends on at least http 0.12.0 but flutter_test specifically requires http 0.11.3+17 (an older version) which makes it fail.
If your app doesn't have too many dependencies that could broke, you can try to upgrade your Flutter version: flutter upgrade.
It most probably will fix this problem. But always be sure to understand that your app might break at unexpected places.
So you're fine if:
either you're doing it for small app
or it's big app at work and it has extensive tests that will tell you something has broken
if big app without tests, be sure to test every important place of the app, where dependencies are being used
Try to change the dependency version that you were added in your pubspec.yaml file
don't use the current or latest version try some previous versions of dependency.
for ex - if you are using latest sqflite version then chnage to previous version of that and then re-run your whole project.
In my case IDE referred to an an older version of dart because of fvm. Seems like 'run' button called fvm flutter run, but not flutter run as I expected. After I deleted fvm folder from the project the problem has gone.
Change depending attributes version inside pubspec.yaml
if it says depands on http *** than change http version
or if it says depands on collection *** than change collection version.

How to determine the tag to Downgrade flutter from 2.0? Cannot build project anymore

I just updated my flutter and my project is not building anymore. I am getting the following error
Because project depends on progress_hud >=0.1.1 which requires SDK
version >=1.23.0 <2.0.0, version solving failed.
pub upgrade failed (1)
Now I read this link here which states that I should checkout that specific Tag. How do I know which Tag is associated with which branch ? Essentially I would like anything closer less than 2.0. Preferably 1.9 or something like that. How do I determine which tag that is?
Don't downgrade your Dart version, there is an issue with that package, it doesn't have the constraints updated : https://github.com/rcpassos/progress_hud/blob/master/pubspec.yaml
As you can see these constraints:
environment:
sdk: ">=1.23.0 <2.0.0"
Doesn't allow to build your app, you have two options:
wait for the owner to update the constraints
Use a fork from another user with the constraints updated, like
this:
Instead of this :
dependencies:
progress_hud: ^1.0.0
Use this:
dependencies:
progress_hud:
git: https://github.com/LampeMW/progress_hud/
Don't Downgrade Flutter. Instead add following tags in
pubspec.yaml
dependency_overrides:
shared_preferences: ">=0.5.12+4"
place your problematic packages lower versions.

Target of URI doesn't exist 'package:english_words/english_words.dart'

I'm learning to use Flutter using Android Studio. I'm going through step by step doc provided by Flutter. At Step:2 Use an external package I'm getting issue importing the english_words package. I have properly added the package in pubspec.yaml and clicked Packages Get which added the dependency but at the time of importing the package in lib/main.dart it is saying
Target of URI doesn't exist
'package:english_words/english_words.dart'.
I have seen many questions on StackOverflow but none of them helped me. Please help!
For some packages, once you do all the process described by the other answers to this question, you have to close the Android project and open it again. As well as the emulator.
Some packages need the restart, others do not need it.
After adding the package in the pubspec.yaml file, you need to execute the command flutter packages get or click on "Packages Get" in the action ribbon at the top of pubspec.yaml file.
Then the dependency and any transitive dependency will be added to the .packages file.
Check this:
https://flutter.io/using-packages/
Solution (For VSCode):
Run flutter packages get in pubspec.yml
Restart VSCode
I had the same issue and went about it like listed below and it worked.
1. Add the package
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
**english_words: ^3.1.5**
Save the pubspec.yaml file
go to your terminal and run 'flutter packages get'
4.Close your simulator and rebuild your cradle
Run the main.dart again and it should remove the error.
This is what worked for me, all the best.
Make sure that english_words is on the base-line with flutter:
Took me a lot of time, but in summary, just save the file pubspec.yaml will do. The command flutter pub get will be ran once u save it, then u can import the package.
There is no need to restart ur editor etc.
My solution was to add the "english_words: ^3.1.5" the version at the moment that I write this, under the "dependencies:" and before the "Flutter:" argument, without the "+" sign.
Hope that helps
I used this and it worked for me... without + sign and version in double quote ""..
english_words: "^3.1.5"
Make Sure that the alignment of english_words is correct inside your pubspec.yaml as it's "space sensitive" :
dependencies:
english_words: ^3.1.5 //two spaces
also never align it using tabs, I don't know why but it never works, and don't use + sign
There are so many methods to solve this issue, most of them will get solved on the second step,if not please try third method also it will work.
Run flutter packages get in pubsec.yaml file (if you are using VS Code it will be easier).
Restart your IDE.
Check it now, mostly it will work. If not try third step.
you have to repair pub caches
flutter packages pub cache repair
I hope it will work. if all methods are not working try to re install flutter.
my friend solution is so simple only add this code line in file pubspec.yaml
english_words: ^3.1.0
like this
dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
english_words: ^3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
it would work perfectly:)
I faced the same issue but I managed to solve it using the steps below:
add the package as an example english_words: ^3.1.0" in 'pubspec.yaml file.
save file or press ctrl+s
//the Output Console will appear this message
[app name] flutter packages get.
Running "flutter pub get" in first_app..., 2.4s
exit code 0.).
3. check main.dart file, the error will be removed.
For me nothing worked. Things resolved only after
Flutter upgrade
in pubsec.yaml file
For those who are still experiencing this problem, it took me hours to figure out what was wrong. Basically, if all the other answers don't work:
Open the test/.packages file on whatever IDE you are using
Locate the package that is not working and go to that directory on your computer.
Delete the whole package. In my case it was the whole english_words package folder.
In the pubspec.lock and .packages file, delete all instances of that package.
run pub get
In the docs of https://flutter.dev/docs/get-started/codelab there is the following code:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
+ english_words: ^3.1.5
The thing which is causing the error is "+ sign". I just removed it and all worked fine for me.
Delete the plus sign "+" in front of english_words (if you have one)
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
english_words: ^3.1.5
I got the same issue.
It is observed only in version 4.0.0 .For lower versions there is no problem.
So here is what you can do to solve this:
Download code for the dependency from :
https://github.com/filiph/english_words
Unzip it Rename it to
english_words-4.0.0
Copy this folder.
Now go to flutter's SDK folder and navigate to
.pub-cache\hosted\pub.dartlang.org
and paste the folder english_words-4.0.0 here. Add dependency in pubspec.yaml file. Now run flutter pub get command.
You are good to go.
Note : How to find the path of Flutter SDK
All you need to do is to restart IDE(Android studio or VSCode)
Having this error message:
Error: Cannot run with sound null safety, because the following
dependencies don't support null safety:
package:english_words
I had to change this dependency english_words: ^3.1.5 to the latest version english_words: ^4.0.0 and make "pub get":
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
english_words: ^4.0.0
provider: ^6.0.0
in your pubspec.yaml file, instead of:
english_words: ^4.0.0
try:
english_words: '4.0.0'
it worked for me