Flutter - Overridden dependencies - flutter

After running "flutter pub get", I got this error:
Warning: You are using these overridden dependencies:
! path 1.6.4

That's not an issue. That happens because you (or any other transitive dependency) may be overriding some dependency that you are already using. For example, if you are using path: 0.X.X and some other dependency use dependency_overrides to make sure that is using path: 1.6.4, it will present you that message.
Overall, you shouldn't have to worry with that and sometimes it is actually required in order to some dependencies work all together.

Please give more details so that i can answer it better. Attach your pubspec.yaml.
But now i can tell you some methods which should work..
first of all see if you are using the latest version of all dependencies or not then:
try:
restarting your ide
flutter clean
if these two don't work then at last try
flutter pub cache repair

I encountered the same error after cloning a flutter repository. I initially mistook the error for being a build issue when it's just a warning that won't stop your app from running.
I solved the build issue I was having with the freshly cloned project by running this command inside the app's root directory: flutter pub run build_runner build

Related

How to solve the error on outdated code when cloning

I am recently want to see and run some other developers code in github and clone it to run in my emulator but it showing some error like this
"Running "flutter pub get" in budgex...
Because budgex depends on basic_utils from path which doesn't exist (could not find package basic_utils at "..\packages\basic-utils-3.3.3"), version solving failed.
pub get failed (66; Because budgex depends on basic_utils from path which doesn't exist (could not find package basic_utils at "..\packages\basic-utils-3.3.3"), version solving failed.)"
i am was trying to install basic_utils package but seem failed how to solve this problem?
Click on the link to get packages in the given environment like VS code, or save your code while pubspec.yaml file is opened – it will get flutter packages for you automatically.
The error says that you are trying to use a library on your local computer: basic_utils; the pub command is searching it in the path ..\packages\basic-utils-3.3.3 but it can't find the library there.
In the pubspec.yaml you should have something like this:
basic_utils:
path: ..\packages\basic-utils-3.3.3
You should be ok replacing this with:
basic_utils: 3.3.3
If the developer has made changes to the library you should ask him the changed library and then update the pubspec with the correct location like described here.

flutter The method 'File.create' has fewer named arguments than those of overridden method 'File.create'

When I try to run my Flutter project, I get errors like:
../../../.pub-cache/hosted/pub.dev/file-6.1.2/lib/src/interface/file.dart:15:16: Error: The method 'File.create' has fewer named arguments than those of overridden method 'File.create'. Future create({bool recursive = false});
Running flutter clean and flutter upgrade didn't help. What's wrong? How do I fix this?
I kept getting the same error, But I solved it adding by adding
file: ^6.1.4 in my dependencies
If you are having the same problem. Make sure you have the latest file dependency.
I think the problem is caused by an outdated reference to file dependency. See this issue.
For fix this, on the project or library folder run:
dart pub upgrade
This command will upgrade your dependencies and the problem will be solved without adding the reference to latest version of file dependency.
I just ran in to this issue and I was on flutter's master channel. I switched back to stable (flutter channel stable) and everything works fine.
For me the packages in my pubspec.yaml were all up to date, but the following fixed it:
Delete pubspec.lock.
Run flutter pub get again.
i solved it by adding file: ^6.1.4 to my pubspec i dont know why this is needed in dependenccies but when i added it worked
this error occured to me when i was trying to update my flutter and packages
but error thrown was of transitive dependencies i guess when u defin in dependencies it over rides the transitive one
but it worked for me
but after wards once project ran i removed the file dependencie from my punspec did a flutter clean and a pub get again and ran the project again it worked without any problem

Cannot run with sound null safety, because the following dependencies [build\windows\flutter\flutter_assemble.vcxproj]

I have shifted my entire code to latest dart version 2.15.1. Now I am trying to run the code and it is giving this error.
Image1
Why I am getting this error. Anyone please help me.
Thanks
This is because some of your dependencies that you are using in your project doesn't support null-safety or Your project itself doesn't support null-safety but using dependencies that supports null-safety. To get rid of this problem you can try upgrading the dependency that is causing the error and if there's no update available for that plugin that run your project using below command :
To Run
flutter run --no-sound-null-safety
To Build
flutter build apk --release --no-sound-null-safety
This error comes when your project or package is not supported on null safety
when you are trying to run the project its gives you an error which you see in your picture
if you want to run without null safety use this command
flutter run --no-sound-null-safety
when you hit this command on your project it should be run if you face any error kindly comment
Press Run
Edit Configurations
Add Additional Run args
--no-sound-null-safety
I just ran into this. I tried to build for Windows and got the null-safety error but the output did not say which packages were the problem, it just showed several paths to Visual Studio.
I then tried to build for Chrome and it did list the packages that did not support null-safety. Hope this helps.
in my case i just type the major version avalaible for the dependency and it works!
from
shared_preferences:
to
shared_preferences: ^2.0.16
With the flutter pub update command, it threw me a reference to the shared_preferences dependency and after investigated options I saw this solution and applied it and it worked fine

Could not resolve project :url_launcher_macos

I create new app in flutter and it's work when I run it, but when I add shared_preferences package, I got this error when I run it
Could not determine the dependencies of task ':url_launcher:compileDebugAidl'.
Could not resolve all task dependencies for configuration ':url_launcher:debugCompileClasspath'.
Could not resolve project :url_launcher_macos.
Required by:
project :url_launcher
Unable to find a matching configuration of project :url_launcher_macos:
- None of the consumable configurations have attributes.
Neither package is compatible with mac
I have faced the same problem and i have fixed this with running following command:
flutter pub cache repair
If this is not working then please try the following:
flutter channel stable then run the commands
flutter clean and flutter upgrade
This worked for me
NOTE:- CLOSE THE FLUTTER PROJECT
Go to Flutter sdk path
Enable the view hidden files in Mac by using CTRL + SHIFT + .
Go to .pub-cache
Go to hosted
Go to pub.dartlang.org
delete this folder url_launcher_macos
Open the project and run app

The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated

I'm running a dart only test in intellij and receiving the following error:
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "pub get" again.
I have tried pub get a number of times. Any ideas? I'm on the dev branch of Flutter (anything using Dart 2.7 pretty much fails with the same or a similar error message).
Edit
I think that if you have a path reference dependency in the pubspec.yaml file it will fail.
Anything like the following fails with the above message if you try to run a dart test in IntelliJ.
dependencies:
test_dependency:
path: ../test_dependency
I'm not suggesting this is a fix for everyone, but it did resolve my particular situation.
Just ran into this error after upgrading flutter from 1.22.6 to 2.0.2 and trying to use build_runner: ^1.12.2 and json_serializable: ^4.1.0 to generate json serialization/deserialization classes & methods.
The problem is apparently related to the pub package when used with relative paths for packages as noted in the following github issues:
https://github.com/dart-lang/pub/issues/2806
https://github.com/dart-lang/pub/pull/2830
One of the commenters in issue 2806 mentioned running flutter create . inside the flutter project folder which rebuilds .dart_tool/package_config.json, adding any missing entries, solving the problem.
No one solved this problem so far?
I've found a staightforward solution and it works fine for me.
You need to close your IDE (VSCode in my case), make sure that is completely closed using process-monitor.
Then open a terminal window manualy in your project folder and run "flutter pub get"
After that just start your IDE normaly and ewerything will work fine.