Install, build and debug a flutter app in WSL2 (Windows Subsystem for Linux).
To install the JDK, execute the following command, which will also install the JRE:
sudo apt install default-jdkAdd the following two lines to /etc/profile (setting the JAVA_HOME environment variable):
export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
export PATH="$JAVA_HOME/bin:$PATH"
Open a new terminal window to automatically source the file.
For Linux desktop development, you need the following in addition to the Flutter SDK:
sudo apt install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-devRefer to Microsoft's instructions below.
- Create a
Downloadsdirectory if it doesn’t already exist, and navigate to it.
mkdir -p $HOME/Downloads && cd "$_"- Download the latest stable release of the Flutter SDK (Right-click and select “Copy link” to copy the address of the archive.):
wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.7.9-stable.tar.xz- Create an
Applicationsdirectory if it doesn’t already exist, and navigate to it.
mkdir -p $HOME/Applications && cd "$_"- Extract the Flutter files from the archive in the
Downloadsdirectory to theApplicationsdirectory.
tar xfv $HOME/Downloads/$(ls -d $HOME/Downloads/flutter*.tar.xz | xargs basename)Run the following command to see if there are any dependencies you need to install to complete the setup (for verbose output, add the -v flag):
flutter doctorAdd the following line to .bashrc:
export PATH="$HOME/Applications/flutter/bin:$PATH"
Open a new terminal window to automatically source the file (or run source .bashrc)
flutter doctor --android-licenses