Flutter and Windows Subsystem for Linux
Asked Answered
E

5

10

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?.

Emelina answered 16/3, 2019 at 23:59 Comment(3)
I think you should definitely install everything on windows. Trying to develop and serve on two different operating systems sounds unnecessarily complicated.Drab
C. Peck, that is not what is being asked here. Bash via the WSL is built into Windows, and it is designed for development among other things.Foetus
I installed the flutter sdk for linux, as given on their website, updated my path and I'm able to run flutter doctor in WSL terminal, but flutter obviously requires android sdk installed and I've been trying to figure out how to do it without installing android studio. I have tried apt install android-sdk, but the version is not compatible. I also tried downloading from dl.google.com/android/repository/sdk-tools-linux-3859397.zip (a link I found online) and extracting, but the version is not compatible. Anybody knows the download link for the latest sdk? google website doesn't have it.Leopard
P
8

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/)

Particiaparticipant answered 28/12, 2019 at 11:21 Comment(0)
M
4

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"

Matchmark answered 28/6, 2019 at 13:29 Comment(0)
N
3

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.

Normally answered 16/4, 2021 at 7:47 Comment(1)
tnks bro. Saved my timeCuzco
M
0

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/

Marlonmarlow answered 26/1, 2021 at 9:21 Comment(0)
C
0

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

Cuzco answered 3/1, 2023 at 5:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.