Flutter and Windows Subsystem for Linux

9.8k Views Asked by At

I have recently switched back from Ubuntu to Windows with Windows Subsystem for Linux using Ubuntu. I want to get in touch with Flutter and would like to be able to use the bash for the Flutter-commands while developing on Windows. Is that possible or should I just install everything for Windows?.

5

There are 5 best solutions below

1
On

You can create an alias like this in your .bashrc :

alias flutter='cmd.exe /c flutter'

then you should be able to use all your flutter commands directly from bash.

0
On

I tried this tutorial to use flutter with WSL.

Problem I faced: For some reason script specified in the "Invoking Windows Flutter from the WSL1 shell" was giving me error.

Workaround I followed: Instead of running the script I created alias as mentioned by @0xManjeet in his answer

0
On

You can setup Flutter inside WSL and develop with VS Code Remote-WSL (on Windows) while having Dart Core extensions installed inside WSL

https://dnmc.in/2021/01/25/setting-up-flutter-natively-with-wsl2-vs-code-hot-reload/

0
On

I tried multiple ways to use flutter with WSL as there is no official way provided.

Restrictions I faced:

  1. Couldn't run the projects stored on WSL.
  2. Couldn't use flutter commands on WSL when it was installed on windows.(Unlike some other tools)

I always prefer installing things on windows and running them on WSL. I just modified the commands a bit and now it works great. I added the following in my .bashrc :

alias winpro='cd /mnt/<DIRECTORY IN WINDOWS YOU WANT>'

flutter() {
    command CMD.exe /c flutter $@
}

Now you can use winpro to shift to windows and flutter will work as usual in WSL.

(Detailed: https://www.yashlamba.com/blogs/1/)

0
On

Flutter - Windows

Android Studio + Emulators - Windows

Execute on bash:

cmd.exe /c flutter run

ImageTerminal of VS Code executing the command "cmd.exe /c flutter run"