Configure Flutter development environment on Manjaro/Arch linux.

Linux is an amazing OS for Flutter development, but setting up Java, Android and the Android tool-chain can be a really difficult.In this blog post I'll show you how to get Flutter working with Android SDK without installing Android Studio.
I'll be using Neovim for writing code , you can use vscode or any other text editor.
Let's start setting up Flutter development environment
Installing Yay package manager
We are going to install almost all of packages from Arch User Repository. For that you need to install yay package manager
Open your terminal and run this command.
pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
Installing Flutter
yay -S flutter
Make sure that you have openjdk 8 or 10 by this command
java -version
if java version is other than 8 or 10 then install openjdk 8 using
sudo pacman -S jre8-openjdk
And put this line in your .bashrc or .zshrc
export JAVA_HOME='/usr/lib/jvm/java-8-openjdk'
export PATH=$JAVA_HOME/bin:$PATH
Set permissions
Yay installs Flutters in /opt/flutter directory.Which can only be accessed by Root user, so we need to set appropriate permissions. Run these commands in your terminal.
sudo groupadd flutterusers
sudo gpasswd -a $USER flutterusers
sudo chown -R :flutterusers /opt/flutter
sudo chmod -R g+w /opt/flutter/
if you get some weird permission denied errors try this
sudo chown -R $USER:flutterusers /opt/flutter
Android SDK and tools
To install Android SDK and other required tools run these commands in your terminal
yay -S android-sdk android-sdk-platform-tools android-sdk-build-tools
yay -S android-platform
User permissions
android-sdk is installed in /opt/android-sdk directory, So need to set appropriate permissions
sudo groupadd android-sdk
sudo gpasswd -a $USER android-sdk
sudo setfacl -R -m g:android-sdk:rwx /opt/android-sdk
sudo setfacl -d -m g:android-sdk:rwX /opt/android-sdk
Android emulator
sdkmanager --list
this command will show you the list of available android system images. Install an android image of your choice. For example.
sdkmanager --install "system-images;android-29;default;x86"
Then create an android emulator
avdmanager create avd -n <name> -k "system-images;android-29;default;x86"
Put these line in your .bashrc/.zshrc
export ANDROID_SDK_ROOT='/opt/android-sdk'
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools/
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin/
export PATH=$PATH:$ANDROID_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/
Accept all of licences by this command
flutter doctor --android-licenses
and run
flutter doctor
Everything should work now except the android studio.

if your licences are not accepted even after running flutter doctor --android-licences try these commands and then run flutter doctor --android-licences again.
sudo chown -R $(whoami) $ANDROID_SDK_ROOT
if licences are still not accepted (happened to me) then try this.
sudo flutter doctor --android-licenses
Create and run new Flutter app
flutter create new_app
cd new_app
flutter run --debug

To run your app on a your mobile phone you need to enable USB debugging. and connect your device to your laptop using a USB.