asdf Flutter version manager (MacOS/ Linux)

I'm a Senior Engineer at Somnio Software, a software development agency. I focus on writing high-quality, scalable, and testable applications. I like to write articles and make videos about tech.
Search for a command to run...

I'm a Senior Engineer at Somnio Software, a software development agency. I focus on writing high-quality, scalable, and testable applications. I like to write articles and make videos about tech.
No comments yet. Be the first to comment.
I wanted to do a quick recap of FlutterCon USA 2024. It was packed with amazing talks, hands-on workshops, and a lot of excitement from the Flutter community. In this post, I’ll share some of my favorite highlights, key takeaways, and a few personal ...

💡 Note: This article is part of the Cleaner Flutter series by my friend Marcos Sevilla to which I contribute. You can find the complete series here. Hello and welcome to the last volume where we will talk about the domain layer of our Clean Archite...

We can't talk about Flutter state management solutions without talking about package:riverpod. Of course, just as I have mentioned in other articles, in my opinion, package:riverpod is more of a dependency injection tool than a state management solut...

💡 Note: This article is part of the Cleaner Flutter series by my friend Marcos Sevilla to which I contribute. You can find the complete series here. After starting in the world of programming we all reach a point where we have to look back on the r...

Without a doubt, Flutter 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. I personally used this solution for several months, but I always had some problems with it.
A few weeks ago I came across asdf, which according to its documentation:
asdfis 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.

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.)
Official docs: here
# MacOS with Homebrew
brew install asdf
# Linux
# Check: https://asdf-vm.com/guide/getting-started.html#_1-install-dependencies
Once asdf is installed, we have to install the asdf flutter plugin
# Installs flutter-plugin for asdf
asdf plugin-add flutter
Github Repo: asdf flutter plugin
# List all available flutter versions
asdf list all flutter
Preview:
# Install a version
asdf install flutter <VERSION_NUMBER>
# Example:
asdf install flutter 2.5.2-stable
# to uninstall
asdf uninstall flutter <VERSION_NUMBER>
# 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>
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.
export PATH="$PATH:$(asdf where flutter)/bin"
export PATH="$PATH":"$HOME/.pub-cache/bin"
With this you will have access to the flutter and dart commands from any terminal 👍.
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.
# Install asdf-dart
asdf plugin-add dart https://github.com/patoconnor43/asdf-dart.git
# More info in: https://github.com/PatOConnor43/asdf-dart
You can share this article to help another developer to continue improving their productivity when writing applications with Flutter.