How to make intl to generate dart files with null safety? - flutter

Flutter package intl: 0.17.0-nullsafety.2 still generates dart files that don't follow null safety practices.
I also tried adding this with no success:
dependency_overrides:
intl: 0.17.0-nullsafety.2
It still generates folder without null safety.
How to force intl package to generate null safety dart files?

I had the same issue. Here are 3 steps to troubleshoot this:
First of all, update intl dependency in pubspec.yaml to this:
intl: 0.17.0-nullsafety.2
If still doesn't work, then add these 2 fields in the root.
dependency_overrides: intl: 0.17.0-nullsafety.2
Generation also can happen via plugin in Android Studio. I used old one (v 0.12) and after I updated to (v 0.14) it started to generate null safety dart files for localization.
I think I stepped on every rock here.

Related

Flutter dependency conflict (versions depend on another )

I want to add avtar in my App but not able to do this because of dependency conflict/ required version error. I also trying to override dependency but its still not working. also trying this commands.
Flutter clean
Flutter pub get
But still not working.
ERROR:-
Because no versions of random_avatar match >0.0.7 <0.1.0 and random_avatar 0.0.7 depends on flutter_svg ^1.0.3, random_avatar ^0.0.7 requires flutter_svg ^1.0.3.
And because flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1 depends on flutter_svg >=0.22.0 <1.0.0, random_avatar ^0.0.7 is incompatible with flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1.
So, because seedwill_demo depends on both flutter_html ^2.2.1 and random_avatar ^0.0.7, version solving failed.
pub get failed (1; So, because seedwill_demo depends on both flutter_html ^2.2.1 and random_avatar ^0.0.7, version solving failed.)
I guess You working on Flutter 2, but Flutter 3 is released. On pub, some libraries are default compatible with Flutter 3. In this case, not always newest library is the best option. You must find which library is incompatible. Can You put pubspec.yaml to this post? We need TWO version of pubspec.yaml. Previous (which have no error with pub get) and new, with this new library. If You show them, I try find the best version of library for You.
I had problems that look alike, and somehow managed to eliminate them by upgrading flutter parts (updating or reinstalling). Have you tried following commands?
flutter clean
flutter upgrade
flutter pub upgrade

Can anyone can tell how to solve this issue as i have tried all existing solutions

I have tried all solutions on the internet and everywhere but nothing works so if someone can help me to solve this issue and this issue occurs when i try to make build for my Flutter App project
this is my yaml file
It looks like you might be using an old version of the plugin_platform_interface package.
you should have a line like this in your pubspec.yaml file:
dependencies:
plugin_platform_interface: ^2.0.1
note that according to the instructions on pub.dev this package only supports null safety in version 2.0 and above. see more at
plugin_platform_interface version log
flutter run --no-sound-null-safety
Check this:
Cannot run with sound null safety because dependencies don't support null safety

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.

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.