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
bin 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
$ cd ~/fvm/versions
$ git clone email@example.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 "
$ mv flutter custom_local
b. Check that your version is listed among all your fvm installed versions:
$ fvm list
Cache Directory: ~/fvm/versions
custom_local (active) # <---- 🎉
3. Configure your project to use your custom flutter version:
$ fvm use custom_local
This should set the version to your local fvm configuration:
Use your Custom Flutter Version
4. Run any flutter command using
fvm flutter (ex:
fvm flutter run) 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
custom_local repository will be testable directly.