Documentation
Guides
Running Flutter

Running Flutter

There are a few ways you can interact with the Flutter SDK setup. These will depend primarily on preference.

Proxy Commands

You are able to proxy any flutter or dart commands to the configured version by adding fvm in front of it.

Flutter

# Use
> fvm flutter {command}
# Instead of
> flutter {command}

Dart

# Use
> fvm dart {command}
# Instead of
> dart {command}

Configure the following alias for a shorthand version of the command:

# aliases
f="fvm flutter"
d="fvm dart"
 
# Now you can use
f run

Benefits

  • Find relative project configurations.
  • Monorepo compatibility.
  • Fallback to global configured version or PATH configured.

Routing

When proxying commands, FVM will look for an SDK in the following order:

  1. Project
  2. Ancestor directory
  3. Global (Set through FVM)
  4. Environment (Flutter version configured on PATH)

Call SDK Directly

Versions installed by FVM are standard Flutter SDK installs. That means you are able to call them directly without proxying through FVM.

Using the symlink will dynamically call the configured version for the project.

# flutter run
.fvm/flutter_sdk/bin/flutter run

Configure the following alias to call the relative project version, without the need to proxy:

fv=".fvm/flutter_sdk/bin/flutter"

If you wish to reroute flutter and dart calls to FVM, i.e., ensure that running flutter on the terminal internally runs fvm flutter, then you could run the below commands.

On Mac

sudo echo 'fvm flutter ${@:1}' > "/usr/local/bin/flutter" && sudo chmod +x /usr/local/bin/flutter
sudo echo 'fvm dart ${@:1}' > "/usr/local/bin/dart" && sudo chmod +x /usr/local/bin/dart

On Linux

echo 'fvm flutter ${@:1}' > "$HOME/.local/bin/flutter" && chmod +x "$HOME/.local/bin/flutter"
echo 'fvm dart ${@:1}' > "$HOME/.local/bin/dart" && chmod +x "$HOME/.local/bin/dart"

If you've installed flutter/dart using native package managers, the binaries might conflict with these new shortcuts, so consider deleting the existing ones and taking a backup for easier restoration.

If you wish to remove these reroutes, just delete the corresponding files as shown below:

On Mac

sudo rm /usr/local/bin/flutter
sudo rm /usr/local/bin/dart

On Linux

rm "$HOME/.local/bin/flutter"
rm "$HOME/.local/bin/dart"

Spawn Command

Spawns a command on any installed Flutter SDK.

fvm spawn {version}

Examples

The following will run flutter analyze on the master channel:

fvm spawn master analyze