You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何同时安装两个Flutter版本(如稳定版/Beta版或2.0.0/1.22.6)并实现快速切换?

Great question! Managing multiple Flutter versions and switching between them quickly is a total lifesaver—whether you’re maintaining an older project that relies on a specific version or testing out new beta features without breaking your stable workflow. Here are the most practical, low-fuss methods I’ve used over the years:

Method 1: Use FVM (Flutter Version Manager)

This is hands down the easiest and most popular way to handle multiple Flutter versions. It’s a community-built tool designed specifically for this use case, and it lets you manage global and project-specific versions seamlessly.

  • Install FVM:
    On Mac/Linux, use Homebrew: brew install fvm
    On Windows, use Chocolatey: choco install fvm
    (Package managers are the simplest route, but you can also grab the binary directly from the official FVM repo if needed.)

  • Install your desired versions:
    Run these commands to add the versions you need:
    fvm install stable
    fvm install beta
    fvm install 2.0.0 (for specific older versions)

  • Switch versions globally:
    To set a default version for all projects, run:
    fvm use stable (or beta/2.0.0, whichever you want)

  • Project-specific version locks:
    The best part? You can lock a project to a specific version so you don’t accidentally use the wrong one. Just navigate to your project folder and run:
    fvm use 1.22.6 --local
    This creates a .fvmrc file in your project. Now, whenever you run Flutter commands in this folder, FVM automatically uses the specified version.

  • Verify the switch:
    Always double-check with flutter --version to make sure you’re on the right version.

Method 2: Manual Version Management (No Tools Required)

If you prefer not to use a third-party tool, you can manually manage multiple Flutter installations. It’s a bit more hands-on, but it works perfectly.

  • Download and store separate Flutter versions:
    Head to Flutter’s official releases page, download the ZIP files for the versions you need, and extract each into a distinct folder, like:

    • ~/flutter-stable (for stable builds)
    • ~/flutter-beta (for beta builds)
    • ~/flutter-2.0.0 (for the specific 2.0.0 version)
  • Create shortcuts/aliases to switch quickly:

    • Mac/Linux: Open your shell config file (~/.bashrc, ~/.zshrc, etc.) and add these aliases:

      alias flutter-stable='export PATH="$HOME/flutter-stable/bin:$PATH"'
      alias flutter-beta='export PATH="$HOME/flutter-beta/bin:$PATH"'
      alias flutter-2.0.0='export PATH="$HOME/flutter-2.0.0/bin:$PATH"'
      

      Save the file, then run source ~/.zshrc (or your config file) to apply changes. Now you just type flutter-stable in your terminal to switch to that version, then verify with flutter --version.

    • Windows: Create batch files (.bat) for each version. For example, flutter-stable.bat would contain:

      @echo off
      set PATH=C:\flutter-stable\bin;%PATH%
      cmd
      

      Double-click the batch file to open a terminal with that Flutter version active.

  • Pro tip: If you want to switch versions permanently until you change it, just update your system’s PATH environment variable to point to the desired Flutter bin folder.

Bonus Tips

  • When switching versions, it’s a good idea to run flutter clean and flutter pub get in your project to avoid dependency conflicts.
  • For CI/CD pipelines, FVM works great too—you can specify the version in your pipeline config to ensure consistent builds.

Hope these methods make switching Flutter versions a breeze! If you hit any snags during setup, feel free to ask for more details.

内容的提问来源于stack exchange,提问作者Abdelrahman Tareq

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 11:24:19