Working with a local version of Flutter using fvm

Working with Flutter, as a best practice I use fvm to manage my Flutter versions and be able to switch from one to another according to the project.

As I wanted to contribute to Flutter, I followed the contributing documentation on how to setup my local forked Flutter sdk until I saw this sentence: "Add this repository's ++code>bin++/code> directory to your path"

I got to thinking: I use fvm to be able to switch from one Flutter version to another in an instant and I should not be juggling with both the versions handled by fvm AND the bin my path is pointing to? I want to keep using fvm to switch to my local Flutter repository and easily test and debug any contributions I would make. I started to look for a way to do just this and here is what I've put together:

you have installed fvm and use it to manage your flutter versions

Setup your local Flutter version 

1. Following Flutter's Setting up the Framework development environment documentation, when you reach step 4. which consists in cloning your own fork of the flutter repository, do so from within your ++code>~/fvm/versions++/code> folder:

++pre>++code>$ cd ~/fvm/versions
$ git clone git@github.com:<github_username>/flutter.git

Configure a custom version with fvm

2. Add a custom version to fvm (https://fvm.app/docs/advanced/custom_version)

    a. Rename the cloned repository into a name starting with "++code>custom_++/code>"

++pre>++code>$ mv flutter custom_local++/code>++/pre>

    b. Check that your version is listed among all your fvm installed versions:

++pre>++code>$ fvm list
Cache Directory: ~/fvm/versions

stable (global)
custom_local (active) # <---- ?

3. Configure your project to use your custom flutter version:

++pre>++code>$ fvm use custom_local

    This should set the version to your local fvm configuration:

++pre>++code># .fvm/fvm_config.json
"flutterSdkVersion": "custom_local",

Use your Custom Flutter Version

4. Run any flutter command using ++code>fvm flutter++/code> (ex: ++code>fvm flutter run++/code>) as you'd do with any other versions. Your app is now running based on your local forked version of flutter, and any changes you make within the ++code>custom_local++/code> repository will be testable directly.

Enjoy ?

1. Shoutout to @LeoAFarias  and all fvm contributors who did an amazing job building this great tool
2. Did I miss anything? Do you do this somehow differently? Reach out to me @Guitoof  to discuss ?

Rejoins nos équipes