DEV Community

Leonard Kioi kinyanjui
Leonard Kioi kinyanjui

Posted on

Setting up Dart for Local Development

I've been learning Flutter for mobile development lately. I like the journey so far and I'm going to be posting stuff I learn along the way. First, I'll show how to set up Dart for local development. I use asdf for managing different versions of language runtimes on my local machine. I found out about it when trying to set up different Python versions. My dev machine comes with Python 3.7 but at work, we use Python 3.6 and I like having the exact version in use. What to do? asdf to the rescue. asdf has a plugin system that allows the installation of different language runtimes for example you can install Python 3.5, 3.6, and 3.8 on the same machine and switch between them. A lot of languages are supported you can find these here.

To setup asdf run:

#!shell
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.7.2`
Enter fullscreen mode Exit fullscreen mode

Replace 0.7.2 with the latest version which you can find here. Next add asdf to your shell like so:

#!shell
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.zshrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Remember to replace .zshrc with your shell-specific config file e.g .bashrc. Reload your config file source .zshrc. You are good to go.

Now let's set up dart. We begin by installing the dart plugin:

#!shell
asdf plugin-add dart
Enter fullscreen mode Exit fullscreen mode

Now we can install dart sdk and tools by running:

#!shell
asdf install dart 2.3.1
Enter fullscreen mode Exit fullscreen mode

Replace 3.2.1 with the latest version or the version you want. You can find these here. You need to choose a global version. This is the version that will be run when you type dart in any shell. You can do this by:

#!shell
asdf global dart 2.3.1
Enter fullscreen mode Exit fullscreen mode

You can also set a version to be used only in the current shell:

#!shell
asdf local dart 2.3.1
Enter fullscreen mode Exit fullscreen mode

Happy darting.

Top comments (0)