new flutter project in vscode has error - visual-studio-code

when i create a new flutter project in vscode it will immediately shows an error in the main.dart file and gives a gradle error when trying to debug.
shown here: main.dart error
"compiler message: lib/main.dart:68:19: Error: Too few positional arguments: 1 required, 0 given."
I've reinstalled dart and flutter plugins. updated the java install.
in debug console i get this:
debug console
added output of flutter doctor -v
enter image description here

I was also facing the same error, but it was always on my test folder.
This is what I did:
On your terminal, make sure you are in your project repository.
Run the flutter pub get command, it worked for me, may be you
should try it too.

Do you possibly have two different versions of the Flutter SDK on your machine? I wonder if one is being used by flutter create and the other for analysis.
If you're sure you only have one, please open an issue on GitHub and attach a log file for me to investigate.

Related

Flutter simply showing 'sysctl -n hw.optional.arm64' returned unexpected output: ''

Not sure which details are relevant so I'll include as many as possible.
Had to upgrade flutter today and instead of working when I typed in 'flutter upgrade' into android studios terminal/Iterm2/terminal zsh I was met with the following response.
'sysctl -n hw.optional.arm64' returned unexpected output: ''
When I search for this issue the only thing i can find is this post which states that sysctl can't be found. The path does appear to be in my .zshrc but still not working. I can't use which or where sysctl as it just says 'sysctl not found'
When I try to upgrade flutter through brew (brew install --cask flutter) it downloads fine but on installing it throws the following error:
==> Purging files for version 3.3.5 of Cask flutter
Error: It seems there is already a Binary at '/opt/homebrew/bin/dart'.
I can't continue working as I need the new flutter version and it seems the web doesn't have much to show for this particular error.
I can't flutter --version, flutter doctor or anything of the sort as I just get the same message.
I'm using:
MacOS monterey 12.6 macbook air.
Android studios
Iterm2
Ohmyzsh
When I open android studios it shows me the following:
"Flutter device daemon #1 exited (exit code 1), stderr: 'sysctl -n hw.optional.arm64' returned unexpected output: '' in a pop up window.
Pubspec has been edited > get dependencies > Upgrade depenedencies: Both of which have the same error as in the title.
The current configured flutter SDK is not known to be fully supported. Please update your SDK and restart intelliJ which I think is what I've been trying to do.
This is an answer I hope will be helpful for others who have the same issue.
Other answers suggested a fix by just updating the path document (.zshrc) but this is what helped me as that did not and my paths were up to date.
Sadly, it's as simple as manually deleting all my flutter SDK files locally. Downloading them again (this time the latest one) and unzipping it into the same place. Didn't even have to update the path).
Worked a charm, issues appear to be all gone except that the dialogue in android studios is still saying that there are dependencies that need getting and upgrading (but doesn't go away even when I've run it).
I solved it by removing the old flutter SDK, downloading the latest version, and setting it up again.
it works perfectly for me!

Flutter Re-run cmake with a different source directory

When I tried to run Flutter app on windows, it gives an error then says Exited Sigterm. or stmh like this.
the error says;
Re-run cmake with a different source directory
cmake files does not match...
etc.
The Steps that helped me to handle this error are;
open your terminal then write following commands
flutter clean
flutter pub get
flutter run
This will remove you build file and re-create it.
Your problem should have solved now.

Error: Target of URI doesn't exist: 'package:flutter/material.dart'. (uri_does_not_exist at [myapp] test/widget_test.dart:8)

I made an app in Flutter and there are no errors on its Dart file but I suddenly end up with errors on widget_test.dart. can you guys help me out. Thanks
Run flutter clean, and then flutter pub get in the terminal respectively.
If that doesn't work, try running flutter upgrade, and then repeating the initial steps.
Finally, if it still isn't working, you can run flutter doctor to see if there's anything glaringly wrong with your project.

Flutter Web crashes with Cannot open file client.js

May I ask your help about this error
It's happen when I'm trying for the first time running my flutter web which using flutter run -d chrome
Launching lib\main.dart on Chrome in debug mode...
Syncing files to device Chrome...
25,220ms (!)
GET /dwds/src/injected/client.js
Error thrown by handler.
FileSystemException: Cannot open file, path = 'C:\Users\Acer\flutter\.pub-cache\hosted\pub.dartlang.org\dwds-2.0.1\lib\src\injected\client.js' (OS Error: The system cannot find the path specified.
, errno = 3)
dart:isolate _RawReceivePortImpl._handleMessage
And if I trying run using
flutter run -d web
It's doesn't thrown any error but on the website it goes blank white nothing shown up.
Anyway thanks for your help
adding the following in the pubspec.yaml worked for me. I am using beta channel.
dependencies:
dwds: ^16.0.1
then run command:
flutter update-packages
I was also facing the same issue, I don't know the exact root cause of the problem but I have a hack to make it work.
I was facing the issue after I deleted .pub-cache folder, so from my recycler bin I picked dwds-2.0.1 folder and reverted back. This hack working
add dwds package in your dependencies and run flutter update-packages. It will work :)

Unable to create flutter project

When running flutter create followed by project name, I receive this error:
Error: Error when reading '../documents/flutter/bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot': No such file or directory
Running "flutter pub get" in pics...
pub get failed (254; Error: Error when reading
'../documents/flutter/bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot': No
such file or directory)
I'm trying to create a new flutter project in xcode. How would I fix this?
'../documents/flutter/bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot': No
such file or directory
It seems like there may be files missing from your Flutter SDK. There should be a file in the Flutter SDK at bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot but this error suggests it's missing.
The easiest fix may be to delete the bin/cache folder which will cause Flutter to re-download the Dart SDK and other components when you next run flutter. This may take a little while depending on your connection, but is the simplest way to ensure the cache folder is complete. I would suggest closing all IDEs/editors when doing this.
I have same issue but the problem was windows defender at real time detection so the solution was to switch off it then create a project...