The current Flutter SDK version is 0.0.0-unknown - flutter

I am not using GIT. As i have seen some posts/questions where users are mentioning they are using GIT and due to that they are getting the error.
Yesterday, I added Image Cropper Plugin and then I restarted the machine. After the restart, it starts giving the error.
The current Flutter SDK version is 0.0.0-unknown.
Because image_cropper 1.2.1 requires Flutter SDK version ^1.12.13 and no versions of image_cropper match >1.2.1 <2.0.0, image_cropper ^1.2.1 is forbidden.
So, because demoapp depends on image_cropper ^1.2.1, version solving failed.
pub get failed (1; So, because demoapp depends on image_cropper ^1.2.1, version solving failed.)
Exited (1)
I run Flutter version command -> Below is the output.
Flutter 1.12.13+hotfix.9 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f139b11009 (6 weeks ago) • 2020-03-30 13:57:30 -0700
Engine • revision af51afceb8
Tools • Dart 2.7.2
I did Flutter Clean and Flutter Pub Get they both didn't fix the issue.
I run Flutter Doctor and here is the output.
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.3 19D76, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the
Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install:
sudo gem install cocoapods
[✓] Android Studio (version 3.1)
[✓] VS Code (version 1.44.2)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.
I am not using Xcode from the beginning.
Any advice on how to fix this issue.
Edit
I checked the path by running echo $PATH.
/Users/rahul/Desktop/flutter/bin
Path is also there.
Edit 2
Flutter Upgrade also didn't helped.

First Restart your system.
Open your downloaded Flutter SDK zip folder (folder you get when you download flutter sdk from official website) and copy packed-refs and config file which is under <flutter_windows_1.22.5-stable.zip\flutter.git> folder
Remove these two files from the existing flutter sdk location in your system(which you extracted earlier) and paste these files again.
Again open android studio and try again by clicking Get dependencies button.
Click on run application.
App will run successfully.

for the new git version you need to config the path of your projet like this
git config --global --add safe.directory D:/path_were_flutter_is_locate/flutter

if it happened to you on Mac OS just install homebrew like on the description on
https://brew.sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
then install git
brew install git

I faced this error because I have multiple user on my system so when i trying to run my project from not-admin user i get this error. i resolved it by using this command
git config --global --add safe.directory C:/flutter
"C:/flutter": is your flutter sdk folder path

Try running flutter doctor if it still shows the flutter version is 0.0.0-unknown, Then mostly your flutter installation is corrupted.
Please follow the steps mentioned in the below link.
https://github.com/flutter/flutter/wiki/Workarounds-for-common-issues#flutter-installation-corrupted

Try running git checkout stable in your flutter installation folder.
I had same issue in Windows and this fix works for me
(Sorry if my english is bad :( )

my flutter installation was git clone --depth=1
so I removed the whole dir: rm -rf flutter
then git clone once again. this time the full repository.
I think it solved the issue.
pub get works again, and flutter can build/run.

The flutter tool determines the Flutter SDK version from the Git tags in your local Flutter Git repository. If you've created a shallow Git clone (i.e., used something like git clone --depth=... or done other manipulations to your Git repository that lost the tag information, the flutter tool will be unable to determine the version number and will report 0.0.0-unknown.
If you find yourself in this state, your best course of action would be to reinstall the Flutter SDK in a supported way (i.e., by following the installation instructions).

After uninstalling and reinstalling flutter you have to create a new flutter app using flutter create app-name. trying to work on the same project will not solve the issue.
This problem fed me up for days.
How i solved this is issue is that i just upgraded the flutter and then deleted the current project while copying the code and created a new project and then pasted the code to the new project
Hurray the issue was solved!!!

for me its due to different issue. Where i should run flutter as normal user not admin. hope this helps.

Go to github page of flutter_image_cropper package, fork it in your space, then change its sdk requirement in its pubspec.yaml file, commit it, push it, now in your project, while importing this package, provide path of your github link to your forked repository ending with .git. It will work perfectly.
Also you can refer Github page for common issues

Related

How to change the current Dart SDK version?

I ran the following commands in my foo project:
iDecode#iDecodes-Mac foo % pub get
Resolving dependencies...
The current Dart SDK version is 2.7.2.
Because foo requires SDK version >=2.12.0 <3.0.0, version solving failed.
iDecode#iDecodes-Mac foo % flutter --version
Flutter 2.6.0-11.0.pre • channel dev
Tools • Dart 2.15.0 (build 2.15.0-116.0.dev)
My pubspec.yaml file has:
environment:
sdk: '>=2.12.0 <3.0.0'
As you can see my current Dart SDK version is set to 2.7.2, my project is targeting a min of 2.12.0 and Dart SDK installed on my machine is 2.15.0. So, how do I change the current Dart SDK version?
This is my ~/.zshrc file
export PATH=/flutter/bin:$PATH
export PATH=$PATH:/$HOME/Library/Android/sdk/platform-tools/
export PATH="$PATH:/$HOME/flutter/bin"
export PATH="$PATH":"$HOME/.pub-cache/bin"
export JAVA_HOME=$(/usr/libexec/java_home)
It seems like you installed Flutter/Dart SDK somewhere using Homebrew. Use which flutter and which dart to see the actual Flutter/Dart command that is taking effect. Once you find where your Dart SDK is you can use
brew uninstall dart
After this when you run which dart it will now point to where your Flutter SDK was installed.
You can also try this way:
Just download that specific flutter version from here. and just set the flutter version in your editor and try to run it will run that specific flutter version but make sure you can't run that with terminal commands. So you need to handle all commands from the Tools option.
set flutter version
Must Run commands from here
The dart version is related with flutter version, see which version is what you need here
https://docs.flutter.dev/development/tools/sdk/releases
Upgrade by running flutter upgrade [check it out here] (update dart sdk for flutter)
Flutter comes with dart by default. Suggestion is to delete old flutter, delete .zshrc and download the latest stable version 2.5.3 for your mac and then give path for it in your .zshrc. Other method is switch to flutter stable by running flutter channel stable and then give flutter upgrade command so it will catch all the stuff from git in you local machine and you'll be good to go.
Simply go to the location where Dart SDK is kept and delete that and install a new Dart SDK version from the official website which is
https://dart.dev/get-dart
I had that same issue
Resolving dependencies... (5.3s)
The current Dart SDK version is 2.17.0.
Because talk_to_me depends on browser >=0.3.1+1 which requires SDK version
<2.0.0, version solving failed
I think we need to uninstall dart and install the correct version
To uninstall dart:
sudo apt purge dart

How do I fix Dart DevTools Widget Inspector that is stuck showing a circular progress indicator?

I had a Flutter app crash while I was debugging it from the Dart DevTool "Logging" page. After this occurred, all I see when I start debugging is that the Widget Inspector shows a circular progress indicator. I'm now testing with the Flutter default app so it's not something in my code. I've tried restarting my computer a couple of times and the behavior hasn't changed.
An answer to a similar problem (Flutter inspector bugging out/freezing in Visual Studio Code) suggested adding dart.embedDevTools": false, to my VSCode settings.json file. I tried that and still get the same behavior, just in a browser window. Aside: this seems to suggest that the problem is not in VSCode. Finally, I also tried running the app from the command line and launching the DevTools application server directly--same problem.
Any ideas of how I might fix this would be appreciated! If there are none, I guess I will have to try uninstalling and re-installing Flutter and Dart to see if that fixes the problem.
>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.2.1, on Microsoft Windows [Version 10.0.19041.1052], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.56.2)
[√] Connected device (2 available)
• No issues found!
>flutter clean
Deleting build... 132ms
Deleting .dart_tool... 4.4s
Deleting .packages... 3ms
Deleting Generated.xcconfig... 4ms
Deleting flutter_export_environment.sh... 2ms
Deleting .flutter-plugins-dependencies... 3ms
Deleting .flutter-plugins... 4ms
>flutter pub get
Running "flutter pub get" in default_app... 1,273ms
>flutter pub global run devtools
>flutter run -d chrome
I finally reached a point where I had time to recover if the reinstall failed so here's what I did to fix this problem:
cd {installdir}\flutter
git clean -xfd
git stash save --keep-index
git stash drop
git pull
flutter doctor
rem • No issues found!
The issue was probably fixed at this point but I went ahead and did the following (except for the two rem steps that I only do when trying to figure out package dependency issues):
cd {projectsdir}\appname
flutter pub upgrade
rem flutter pub outdated
rem flutter pub deps -s list
flutter clean
flutter pub get
cd ..
code appname // Open folder in VScode
<F5>
At this point, DevTools Widget Inspector and Logging are working again!!
Thanks to Suragch who posted the Git steps in an answer to How do you uninstall Flutter completely and properly from a Mac?.
It would be nice to add this info to the Flutter Windows install page but I'm not sure how to even suggest that.
Final Thoughts
There could be issues where this refresh doesn't work. In that case--and in the case where one didn't install flutter as a git repository--I believe that the fix would be:
* delete the flutter directory where you installed flutter,
* remove the paths related to flutter from your environment variable PATH, and
* install Flutter per the install page.
I caution that I haven't tested this approach! If anyone encounters a problem that forces them to resort to this fix, posting an answer here would be appreciated.

How do I upgrade an existing Flutter app?

I have an existing Flutter app that I built half a year ago. I checked on pubspec.lock, it has this line:
sdks:
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.16.0 <2.0.0"
So I assume the app was built for Flutter v1.16.
How do I upgrade this app to use the latest Flutter's version? Running "flutter doctor" gives me [√] Flutter (Channel stable, 1.22.3, on Microsoft Windows [Version 10.0.19041.630], locale en-US), so my SDK is already updated to the latest version.
Interestingly, when I create a new app from scratch, the pubspec.lock does not have any information about the Flutter's version. The same section now contains only this: sdks: dart: ">=2.10.0-110 <2.11.0". In the future, how would I know which version was this app running?
I have tried running "flutter upgrade" within my app, but that was to upgrade the SDK, not the Flutter version of the app. So how do I upgrade my app to use the latest Flutter version? Or is it always built using the latest version of the SDK? Can't I target my app to build with specific version of Flutter?
To update the project to null safety follow these steps:
Side note: change the flutter version in pubsec.yaml, make new project and copy the following line:
sdk: ">=2.12.0 <3.0.0"
Then follow the steps:
Run flutter upgrade in the terminal to upgrade Flutter
Run dart migrate to run the dart migration tool.
Solve all errors which the migration tool shows.
Run flutter pub outdated --mode=null-safety to print all outdated packages.
Run flutter pub upgrade --null-safety to upgrade all packages automatically.
Check the code for errors and solve them (Very important).
Run dart migrate again and it should now be successful. Follow the link to checkout the proposed changes.
Press the "Apply Migration" button.
Check the code for errors again and fix them.
Your project should be updated now.
Referenced from this website.
Go ro the root directory of your flutter project and run flutter upgrade. This will upgrade both your existing flutter project and flutter SDK to latest version.
Run the command:
flutter upgrade
Additional for upgrading to latest stable version only
If you want to upgrade to latest version only then please first check your current flutter channel
Step 1:
Check for Stable channel
flutter channel
You will get output like this:
beta
dev
master
* stable
If output was not like this then please proceed to Step 2 or directly proceed to Step 3
Step 2:
Switch to flutter stable channel
flutter channel stable
Now you will get output like this:
beta
dev
master
* stable
Step 3:
Run the below command to upgrade to latest stable version of flutter
flutter upgrade
Inside your project root, run below command
flutter upgrade
This command will update the Flutter SDK locally installed on your workstation, wondering how does that make sense?
After you run, above command flutter upgrade the SDK is updated locally and whenever you build or run your flutter app now, it should always pick up the latest stable version (stable channel) installed locally.
to check run,
flutter channel
you should get something like below based on what version is installed locally on your workstation.
Flutter is already up to date on channel stable
Flutter 2.0.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 4d7946a68d (3 days ago) • 2021-03-18 17:24:33 -0700
Engine • revision 3459eb2436
Tools • Dart 2.12.2
You can always switch to a different channel with below command,
flutter channel dev
flutter upgrade
Answer to - the Flutter SDK locally installed on your workstation, wondering how does that make sense?
Open your pubspec.yml file and see below:
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
Where version: 1.0.0+1 is your flutter app version
When you run command flutter run your app should pick up the environment as defined which is sdk: ">=2.1.0 <3.0.0"
With all dependencies as defined under,
dependencies:
flutter:
sdk: flutter
where sdk: flutter states that the SDK should be pulled from your locally installed SDK version.
Recall, how you had installed the Flutter SDK first time, on your local workstation, as below MAC example, See all SDK releases
cd ~/development
unzip ~/Downloads/flutter_macos_2.0.3-stable.zip
later, Update your path, and run flutter doctor.
OR
git clone https://github.com/flutter/flutter.git -b stable
later, Update your path, and run flutter doctor.
Note: You may check your pubspec.lock file that may look like below,
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
flutter: ">=1.16.0" <---- Use SDK greater than this installed locally
I will show you an easy way to migrate old code projects.
My recommendation is not to work on the existing old project. Instead, create a new project where you can turn your existing project code into new clean, tidy code at a time.
Now put a line of code on the existing old code project terminal as below.
$ flutter create -t <project-type> <new-project-path>
For example, your terminal code like,
PS C:\Users\habib\VScodeProject\git_ripository\simple-weather-old> flutter create -t app C:\Users\habib\VScodeProject\git_ripository\simple-weather-new
Done.
After that, Your new project will no more show any system problems, like gradle problem, android manifesto problem i.e.
If you want to see more about flutter migrating: [See this flutter doc]
if you upgrade your project, but still have problem. then please check your path spellin is ok or not!?
I also face this problem. after upgrading project it won't work for me. then i look to my code, there was miss path.

Android Studio Dart And Flutter Plugin is not installed

Here is the flutter doctor result:
[√] Flutter (Channel stable, 1.22.1, on Microsoft Windows [Version 10.0.18362.30], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[!] Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
I have already installed the flutter plugin. But the problem still exists. How can I fix this?
Just run this on your terminal (Mac users)
ln -s ~/Library/Application\ Support/Google/AndroidStudio4.1/plugins ~/Library/Application\ Support/AndroidStudio4.1
Well hello all
I would suggest you all to follow the steps what flutter documentation sites tells you to do
For windows-->There are some people who got detected flutter and dart plugins by the flutter doctor and few are not
I got this issue when I tried to install ...
I did everything like installed flutter and dart plugin still my flutter doctor haven't detected the plugins ...
following steps worked for me
flutter channel dev
flutter upgrade
flutter config --android-studio-dir="C:\Program Files\Android\Android Studio"
flutter doctor -v
note :--- flutter config --android-studio-dir="C:\Program Files\Android\Android Studio" should be example flutter config "C:\Program Files\Android\Android Studio"
above steps worked for me i hope it will helps you too :)
change channel master to dev.
then upgrade.
flutter channel dev
flutter channel upgrade
try again
flutter doctor
Note: I think it's Android Studio 4.1 issue...
Since you say you have flutter plugin installed in Android Studio, and if Android Studio correctly shows your installed plugin, there is no reason to believe any third-party tool reporting otherwise.
Also, this will not affect your flutter development and your IDE plugins will work as expected inside the IDE and flutter tool's commands work independent of the IDE in use.
Android Studio 4.1 apparently changed its default plugin install path.
Related github issue: [flutter_tools] IDE plugin validators should be deprecated #61246
Flutter does not directly use the IDE plugins, so doctor failing to detect them does not affect any behavior (it's just annoying).
open terminal:
run> flutter channel dev
run> flutter channel updrade
open terminal:
Mac User:
flutter config --android-studio-dir=/Applications/Android\ Studio.app
Reinstall Flutter Plugin from Android Studio
Are you using Android Studio V 4.1?
With Android Studio V4.1 there is a problem.
Try to reinstall Android Studio but Version 4.0.1 and try it again, chances are this will fix your problem.
Open Android studio
Follow the Path Configure > Plugins > marketplace > search Flutter & Dart > Install
Restart IDE(Android studio)
Open Terminal and Export Flutter Path
and run flutter doctor -v
If you are upgrading for an existing project:
Run
git clone https://github.com/flutter/flutter.git
in your terminal.
The be sure to delete the Flutter folder in your App's root directory. Otherwise you will get over 50k errors popping up
Check your flutter PATH
which flutter
if you get /path-to-flutter-sdk/bin//flutter or similar you may have added an extra / in your $HOME/.rc_file. Remove the last '/', restart terminal and try again
this worked for me
flutter channel dev
flutter doctor

Flutter Desktop Linux build failed

When I try to build my app to Flutter Desktop its fail with this message:
Launching lib/main.dart on Linux in debug mode...
Exception: Build process failed
My configuration is:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.19.0-2.0.pre.142, on Linux, locale pt_BR.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 3.6)
[✓] Connected device (1 available)
Can anyone know how to fix this?
Thanks
I had the same issue.
First I ran flutter run -v -d linux, I followed the log and I noticed it an OS Error
Unhandled exception:
FileSystemException: Setting current working directory failed
So, I firstly switch to the master channel (solution for some people), run flutter upgrade and I was getting the same error.
My working dir is /home/xylia/Flutter\ Apps/github_pages and I felt it might be the space from the folder name (I had an issue like that once), so I created a new folder without space and it worked!
I am not totally sure if changing channel to master helped but there is no harm in doing it
I don't know if you already found a solution but for everyone having this problem, I solved it by doing the following:
Inside your project root directory delete the linux folder, like rm -rf linux.
Run flutter clean to delete the build folder and other related files.
Then run flutter create . to make flutter recreate your linux folder.
I had the same problem my fix was to create/run the flutter project on primary SSD/HDD drive.
In my case, it was a dependencies problem. I was trying to use svg_flutter package in a desktop app (which is not supported).
Try running flutter run -v -d linux and check if any error message corresponds with new packages that you added recently.