Where can I see the flutter version used in a flutter project? Is there a file inside the project directory where I can see it? I think it is not specified inside the pubscpec.yaml file
So far, I think the specific version can not be found but only what versions can be used in a project. It can be found at the bottom part of pubscpec.lock file
pubspec.lock screenshot
It will not show version project wise. It will overall flutter version that you have installed in your system. For that:
Open your flutter project root directory in Command Prompt or Terminal type:
flutter --version command.
After typing the above command hit enter and You’ll see it will display us the currently installed flutter and Dart version in your computer and also tells us which version type we have installed like Stable or Beta.
Note: There is no such feature/command to check about which version of flutter you have used in Specific project.
Check this thread it will give you more idea:
https://github.com/flutter/flutter/issues/14230
All projects you run will use the flutter sdk installed in your machine/computer from where you specified its location from. So if the version the project uses don't match with the version you've and they conflict, you will have errors and if there is a huge gap and breaking changes, you'll need to either upgrade or downgrade the sdk. But most of the time, things are deprecated before they just become breaking changes and so you shouldn't have big issues. So the best thing to do is usually to upgrade. First check your sdk version via flutter --version. If its outdated, use flutter upgrade to upgrade it.
You can either run flutter --version to check flutter version installed on your machine or check it in your pubspec.lock file for current flutter version in your project
sdks:
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.16.0 <2.0.0"
Related
Warning: `dart` on your path resolves to /usr/lib/dart/bin/dart, which is
not inside your current Flutter SDK checkout at /home/ankit/flutter.
Consider adding /home/ankit/flutter/bin to the front of your path.
This exception started when the flutter was updated. How do I solve this?
The Problem:
This is happening because you have a separate installation of Dart on your system. The Flutter SDK includes and manages it's own dart SDK, but you can use the dart SDK separately.
Why it Matters
Flutter recommends that you use the dart SDK included with Flutter because Flutter manages it - It will automatically use and upgrade supported versions when using the flutter upgrade command on your terminal, and during initial install.
Flutter is noticing that you have a dart SDK install that did not come with the Flutter SDK. It's giving you a warning because of the possible differences in versions (and possibly other configurations) that could prevent an optimal flutter development experience.
System Path
Here's an explanation of path. You will probably need to set your path environment variables to get the whole fix.
This link shows the official Apple guide to working with the terminal environment variables (including path) but a quick google around should help you find any answers you can't find here.
The path resolves from "front" to "back" - meaning that if the executable in question occurs twice, it will grab the first one. Flutter doctor wants you to add the flutter dart path at the front so that subsequent dart calls will resolve to the Flutter Dart SDK.
The High-Level Solution
Unless you're doing dart development outside flutter, you don't need an additional dart SDK. Most of the time the Flutter dart SDK will work for cases besides flutter as well.
I would recommend removing your other dart install, and using the dart install that comes with flutter. This process will vary depending on how you installed the other dart SDK.
TLDR/Quick Fix
based on what you provided, run this on your Zsh command-line:
export PATH="/home/ankit/flutter/bin:$PATH"
It will only work until you restart your computer.
I would like to test my application / package running on an older version of Flutter, e.g. specifically Flutter v2.2.3.
There are 2 commands, flutter upgrade and flutter downgrade which might seem to be relevant, but how do I select the specific version of Flutter I want to use? flutter upgrade --help and flutter downgrade --help do not provide any extra information.
Recommended (git): Just checking out a specific commit in the Flutter repo
Change directory to your flutter installation folder, e.g. /opt/flutter.
git checkout the git tag (change to the branch pointed by the tag). For example, there is a git tag called 2.5.0 for the version 2.5.0, so run git checkout 2.5.0. (Thanks Eugene :) )
Or alternatively, if I want version 2.5.0, I can get the commit SHA (ref) from the Flutter SDK releases page. That website says the ref for 2.5.0 is 4cc385b. At the flutter installation directory, run git checkout 4cc385b.
Then in the terminal, run flutter (or any specific flutter command) to download and build this version of flutter.
Using FVM (Flutter version Management)
You also specify the specific version of Flutter using FVM, e.g. fvm use 2.5.1
Download the specific version of Flutter from Flutter SDK releases and install it.
This is the slowest way, as you would have to download the entire repo again.
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
I have some older projects built on flutter 1.22.6 and now I am working on latest version of flutter but there often comes need when I've to work on previous projects non null safety one's so when I try to downgrade flutter by giving command flutter downgrade 1.22.6 it tells me to downgrade to 2.5.2 and if I try to switch channel and then downgrade it downgrades to 2.5.2 first and then tells there is no version related to 1.22.6. This method used to be working before but now its not working anymore. I don't want to download zip files and then replace again flutter every-time I just want it to be done by cli.
My OS is windows 11
You can use flutter Version Manager fvm its specifically made to control flutter versions plus along with that you can install flutter sidekick as well. I am attaching link for you.
FVM Flutter Sidekick
Since you can no longer downgrade flutter versions, I have found the best way to do this is:
Download desired flutter version
Locate current 'flutter' folder and replace it with the desired version
if you run --flutter version after, it should show the correct version
I believe my Flutter SDK version is being erroneously reported and do not know where the conflict is.
When running flutter doctor it reports Flutter 2.2.3 • channel stable. However, the bottom toolbar in VSCode displays Flutter: 2.0.4.
Is there a reason VSCode and terminal would report the Flutter version differently? And how can I ensure I am running the correct SDK version?
Look into "dart.flutterSdkPath" setting in vscode and change if needed. The problem could be with you having multiple versions of Flutter on the disk and auto-find fails to find the correct one (last version), manually override.
In my case my path( environment variables) of SDK was set wrong check yours first
and if still not worked try running commands
Flutter clean
Flutter upgrade
I'm working with Flutter to make a Mobile App using the stable Flutter SDK release. But I also want to try Flutter Desktop and Flutter Web that are not part of the Flutter stable channel yet, but are present on the Flutter dev channel.
My question is... How can I try Flutter Desktop and Flutter Web without override the Flutter stable release on my machine?
You'll need to setup alias to switch between different environments easily.
See here a detailed article for that.
I found this Dart package called Flutter Version Management that does exactly what I want.
As the docs says:
Flutter Version Management: A simple cli to manage Flutter SDK versions.
Features:
Configure and use Flutter SDK version per project
Ability to install and cache multiple Flutter SDK Versions
Fast switch between Flutter channels & versions
Dynamic SDK paths for IDE debugging support.
Version FVM config with a project for consistency across teams and CI environments.
Set global Flutter version across projects
https://github.com/leoafarias/fvm
Now I just need to add FVM_HOME/default/bin to the PATH and FVM will take care of everything...
Two solutions
Put the installation files in two different directories one with stable and the other dev and add one of them to the path then you can change the path variable when needed to use the other channel.
Put the flutter repository file in two different directories one with stable and the other with dev then,
add the first installation to the path then add an alias to point to the second installation directory.