🔁 asdf Flutter version manager (MacOS/ Linux)
Tags: flutter, asdf
Published: 2021-10-08 21:47:07


Without a doubt, [Flutter](https://flutter.dev/) is a framework that is constantly changing. And as developers, we need to be ready and have more than one version installed at the same time.

One of the most famous solutions for this problem is [Flutter Version Manager by leofarias](https://github.com/leoafarias/fvm). I personally used this solution for several months, but I always had some problems with it.

A few weeks ago I came across [asdf](https://asdf-vm.com/), which according to its documentation:

> `asdf` is a tool version manager. All tool version definitions are contained within one file (`.tool-versions`) which you can check in to your project's Git repository to share with your team, ensuring everyone is using the exact same versions of tools.
> 

![https://media.giphy.com/media/3oKIPqsXYcdjcBcXL2/giphy-downsized-large.gif](https://media.giphy.com/media/3oKIPqsXYcdjcBcXL2/giphy-downsized-large.gif)

In a nutshell, it allows us to handle multiple versions of different tools (which I found interesting as it could be useful for other tools like: `cocoapods`,`ruby`,`node.js`, etc.) 

## How to use asdf with flutter?

Official docs: [here](https://asdf-vm.com/guide/getting-started.html#_1-install-dependencies)

### Install asdf

```bash
# MacOS with Homebrew
brew install asdf

# Linux
# Check: https://asdf-vm.com/guide/getting-started.html#_1-install-dependencies
```

### ASDF Flutter plugin

Once asdf is installed, we have to install the asdf flutter plugin

```bash
# Installs flutter-plugin for asdf
asdf plugin-add flutter
```

[Github Repo: asdf flutter plugin](https://github.com/oae/asdf-flutter)

### install/uninstall a version

```bash
# List all available flutter versions
asdf list all flutter
```

Preview:

![carbon](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iql8kn8mjtqju4igp2do.png) 

```bash
# Install a version 
asdf install flutter <VERSION_NUMBER>

# Example:
asdf install flutter 2.5.2-stable

# to uninstall
asdf uninstall flutter <VERSION_NUMBER>
```

### Local and global version

```bash
# Defines a global flutter version to be used 
asdf global flutter <VERSION_NUMBER>

# Defines a local flutter version to be used 
asdf local flutter <VERSION_NUMBER>
```

## Export to $PATH

To have access to the currently selected version, you need to export asdf flutter to  `$PATH`.In my case, I added the following line to my `/.zshrc.`

```bash
export PATH="$(asdf where flutter)/bin":"$PATH"
```

With this you will have access to the `flutter` and `dart` commands from any terminal 👍.

## ... and dart?

`dart` is included by default with the `asdf flutter plugin`. However, sometimes you need a different `dart` version. This can be accomplished by running the same commands mentioned above, but substituting `flutter` with `dart`. 

```bash
# Install asdf-dart
asdf plugin-add dart https://github.com/patoconnor43/asdf-dart.git

# More info in: https://github.com/PatOConnor43/asdf-dart
```

### As always...

You can share this article to help another developer to continue improving their productivity when writing applications with Flutter.

There's a Spanish version of this article on Medium. You're welcome. 🇪🇸

Also, if you liked this content, you can find even more and keep in contact with me on my socials:

Also, if you liked this content, you can find even more and keep in contact with me on my socials:

- [dev.to](https://dev.to/elianortega) - where you're reading this article.
- [GitHub](https://github.com/elianortega) - where are my code repositories in case you like the examples.
- [GitHub NoScope](https://github.com/NoScopeDevs) - donde están los repositorios de código en conjunto del canal de YouTube y directos de Twitch con Marcos.
- [LinkedIn](https://www.linkedin.com/in/elianortega/) - where I connect professionally.
- [Twitter](https://twitter.com/ElianMOrtega) -  where I express my short thoughts and share my content.
- [Twitch](https://www.twitch.tv/noscopedevs) - where I do informal live shows from which I take clips with specific information.
- [YouTube](https://www.youtube.com/c/noscopedevs) - where I publish the clips that come out of my lives.

> 🇪🇸 Versión en español de este articulo [aquí](https://elianmortega.medium.com/asdf-flutter-version-manager-macos-linux-cd869fc0990b)