Installing Flutter on WSL2 — Windows 10

Using the Paradox Oh-My-Posh theme with my custom configuration in Windows Terminal.

Install Flutter

Create a Downloads directory if it doesn’t already exist, and navigate to it.

mkdir -p $HOME/Downloads && cd "$_"
Flutter SDK releases for different platforms and channels.
wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_2.8.1-stable.tar.xz
mkdir -p $HOME/Applications && cd "$_"
tar xfv $HOME/Downloads/$(ls -d $HOME/Downloads/flutter*.tar.xz | xargs basename)
echo -e "\n# Flutter\nexport PATH=\$HOME/Applications/flutter/bin:\$PATH" >> $HOME/.bashrc
source $HOME/.bashrc
flutter --version
Flutter successfully installed!
flutter doctor

Install Android SDK

Install the unzip utility and the default-jdk development utility

sudo apt install unzip default-jdk -y
mkdir -p $HOME/Downloads && cd "$_"
Latest releases of Android SDK Command-Line Tools for different platforms.
wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
mkdir -p $HOME/Applications && cd "$_"
unzip $HOME/Downloads/$(ls -d $HOME/Downloads/commandlinetools-linux*.zip | xargs basename) -d ./android
version=$($HOME/Applications/android/cmdline-tools/bin/sdkmanager --sdk_root=$HOME/Applications/android --version | head -n1);
echo $version;
mkdir -p $HOME/Applications/android/cmdline-tools/$version
mv -vt $HOME/Applications/android/cmdline-tools/$version/ $HOME/Applications/android/cmdline-tools/!($version)
echo -e "\n# Android\nexport PATH=\$HOME/Applications/android/cmdline-tools/$version/bin:\$PATH" >> $HOME/.bashrc;
source $HOME/.bashrc
sdkmanager --install "system-images;android-31;google_apis;x86_64" "platform-tools" "platforms;android-31" "build-tools;31.0.0" "cmdline-tools;latest"
sdkmanager --list_installed
Packages successfully installed via sdkmanager!
echo -e "export PATH=\$HOME/Applications/android/emulator:\$PATH" >> $HOME/.bashrc;
echo -e "export PATH=\$HOME/Applications/android/platform-tools:\$PATH" >> $HOME/.bashrc;
source $HOME/.bashrc

Configure Flutter

Configure flutter to use the Android SDK.

flutter config --android-sdk $HOME/Applications/android/
sdkmanager --licenses
flutter doctor
The Android SDK dependency is all set up and ready to go!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Josh Kautz

Josh Kautz

DevOps Software Engineer II at C.H. Robinson