hello everyone. I am nuts, my official account, "nuts front end".
Today, let's introduce the flutter version control tool FVM
FVM switches the Flutter version of VSCode
With the release of flutter 2.5.0, I believe many students are excited and trembling hands. They want to try a wave quickly and be a crab eater. I was also in such a mood. My mind was hot. I updated the local version of flutter to 2.05.0. The crabs were eaten up, but when I returned to the project (1.20.4 adopted by the company's project), it turned red, All kinds of error reports, I drop a good ~, and quickly return the version to the previous stable version!
It's naive to want to eat crabs and take into account the company's project code. Fortunately, https://github.com/leoafarias/fvm Can meet the demand. Here I introduce a version management artifact FVM of fluent. I give two installation methods,
Choco and choco
FVM can specify the Flutter version for the project by installing multiple Flutter SDK versions on the user's machine, or quickly switch between versions to solve the problem that only one Flutter version is compatible with different projects.
Installing fvm on windows
Method 1: install choco first
Official website:
https://chocolatey.org/
Run the command line as a powershell administrator
If not, first open a powershell window, then right-click the taskbar and select the first one to enter
Enter command
- cmd installation
You can copy directly. Note that you need to run as an administrator
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
- PowerShell installation
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Check that the installation was successful
choco -v
- to update
choco upgrade chocolatey
Can be installed successfully
Common instructions
choco list -li view locally installed software
choco search nodejs find installation packages
choco install sublimetext3 Download
choco uninstall sublimetext3 uninstall
choco upgrade sublimetext3 update
Next, install the fvm
choco install fvm
Method 2: install fvm in pub mode
pub global activate fvm
You can set system environment variables
1. Syntax example
VSCode configuration
Now we will configure VS Code here, and we will see how to complete the VS Code process.
Directory, we can see all the versions installed by FVM in the code
Here you are prompted to add the following in settings.json.
{ "dart.flutterSdkPaths": ["D:/fvm/versions""] }
Use the fvm command and enter fvm. The following message appears: the configuration is successful and you can start using fvm for management.
To get the above path, we will execute the fvm list command
// copy this path Versions path: $YOUR_PATH/fvm/versions
Enter cmd + shift + p to use the sdk, and then enter change sdk. Now you can choose your favorite version.
Initialize project
$ fvm flutter create .
Android studio
- Go to Languages & Frameworks - > fluent or search for fluent and change the path of fluent SDK.
- Copy the * * * absolute * * * path of the fvm symbolic link to your project root directory. Example: / absolute path /. fvm / fluent_ sdk
- Apply changes.
- Restart Android Studio to view the new settings for the app.
You can now run and debug with the selected version of fluent.
Flutter version switching
Check the local version with fvm list before version switching
Cache Directory: D:\fvm\versions2.5.12.5.02.2.31.20.4
Then use fvm list to switch the version you want
PS E:\work\dc-client\app_proj> fvm use 1.20.4Project now uses Flutter [1.20.4]
Other settings are the same as those of the computer terminal. You can refer to: github.com/leoafarias/...
project
FVM will create a relative symbolic link. FVM / fluent in your project_ SDK to the cache of the selected version. Add it to your. gitignore
.fvm/flutter_sdk.gitignore.fvm/flutter_sdk
Cache directory
You can configure the fvm cache directory fvm by setting the environment variable_ HOME. If not set, the default fvm path is used. You can also change the directory by setting -- cache path on the configuration. See below
List configuration
fvm config
Set cache path
fvm config --cache-path <CACHE_PATH>
to configure
You can change some configurations on the FVM. All settings set on the CLI are compatible with Sidekick(GUI).
Common commands
Generally, you need to view the instructions of the command through -- help.
$ fvm --helpFlutter Version Management: A cli to manage Flutter SDK versions.Usage: fvm <command> [arguments]Global options:-h, --help Print this usage information. --verbose Print verbose output.Available commands: config Set configuration for FVM flutter Proxies Flutter Commands install Installs Flutter SDK Version list Lists installed Flutter SDK Version releases Lists Flutter SDK releases. remove Removes Flutter SDK Version use Which Flutter SDK Version you would like to use version Prints the currently-installed version of FVMRun "fvm help <command>" for more information about a command.
- config: configure fvm
- Fluent: proxy for fluent commands
- Install: install the Flutter version
- list: view the installed version of Flutter
- releases: check the release versions of the shuttle SDK
- remove: deletes an installed version of a Flutter
- Use: select the version you want to use
- Version: view the version of the installed fvm
For more usage methods of subcommands, we can view them through FVM help < command >, for example:
$ fvm help useWhich Flutter SDK Version you would like to useUsage: fvm use [arguments]-h, --help Print this usage information. --global Sets version as the global version. Make sure Flutter PATH env is set to: /Users/oheroj/fvm/default/bin --force Skips command guards that does Flutter project checks.Run "fvm help" to see global options.
- -h. – help: you can view more usage information
- – Global: set this version as the global version
- – force: skip executing the fluent project check command
The routine of command learning is to use help. You can learn other commands by yourself.
install
Install the version of the Flutter SDK. Enables you to install the Flutter version or channel.
Usage: fvm install - # Install the version found in the project configuration fvm install {version} - # Install a specific version option: - H, -- help print this usage information. - s, -- skip setup skip shutter setup after install
delete
Delete the Flutter SDK version. Any projects that depend on this version of the SDK will be affected.
Usage: fvm remove {version}Option: -h, --help Print this usage information. --force Skips version global check.
list
Lists the installed versions of the fluent SDK. The cache directory used by the FVM is also printed.
Usage: fvm listOption: -h, --help Print this usage information.xxxxxxxxxx List#Usage: fvm listOption: -h, --help Print this usage information.
releases
View all available Flutter SDK versions for installation.
Usage: fvm releasesOption: -h, --help Print this usage information.
doctor
Displays information about the environment and project configuration.
Usage: fvm doctorOption: -h, --help Print this usage information.
route
When the agent commands, FVM will look for the sdk in the following order.
- project
- Parent directory
- Global (set via FVM)
- Environment (Flutter version is configured on PATH)
Configure global version
fvm global {version}
Project multiple options
You can configure multiple versions of the fluent SDK for each project environment or release type. FVM follows the same Convention as Flutter and calls it flavors
It allows you to create the following configurations for your project.
{ "flutterSdkVersion": "stable", "flavors": { "dev": "beta", "staging": "2.0.3", "production": "1.22.6" }}
For no flavor version
To select the version of the fluent SDK for a specific version, you only need to use the use command.
fvm use {version} --flavor {flavor_name}
Switch flavor version
Get the version configured for flavor and set it to the project version.
fvm flavor {flavor_name}
View flavor
List all configured flavors:
fvm flavor
common problem
Invalid kernel binary or sdk hash when running FVM
There are several reasons for this. However, this means that the FVM snapshot is not compatible with the installed Dart version.
Do the following:
- On windows, make sure that your env variables are arranged in the order described in [Windows environment variables in PATH].
- Run dart pub global deactivate fvm
- Run dart pub global activate fvm
Order of Windows environment variables in PATH
Dart is built into the Flutter. Therefore, when you run dart and fluent separately, you will find some conflicts. This is the correct order of dependencies we found to avoid problems.
- Global package publishing cache
- Dart SDK (if installed outside of fluent)
- Flutter SDK
It should be like this.
C: \ users < users > \ appdata \ roaming \ pub \ cache \ bin
C:\src\flutter\bin\cache\dart-sdk\bin
C:\src\flutter\bin
Command 'pub' not found
If you get the Command 'pub' not found, make sure to attach export PATH="$PATH:/usr/lib/dart/bin" to your ~ /. bashrc (restarts every time you open the bash shell) or ~ /. profile (reads only at login).
choco list -li view locally installed software
choco search nodejs find installation packages
choco install sublimetext3 Download
choco uninstall sublimetext3 uninstall
choco upgrade sublimetext3 update
reference resources:
https://fvm.app/docs/getting_started/overview