Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter and Windows Subsystem for Linux

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

like image 836
Daniel Braun Avatar asked Mar 16 '19 23:03

Daniel Braun


People also ask

Can flutter be used for Linux?

Flutter provides support for compiling a native Windows, macOS, or Linux desktop app. Flutter's desktop support also extends to plugins—you can install existing plugins that support the Windows, macOS, or Linux platforms, or you can create your own.

Can I use Windows Subsystem for Linux?

WSL also allows you to run Linux command-line tools and apps alongside your Windows command-line, desktop and store apps, and to access your Windows files from within Linux. This enables you to use Windows apps and Linux command-line tools on the same set of files if you wish.

Is flutter better on Linux or Windows?

Linux is improving rapidly but most game developers still target the Windows audience. For corporate networks Windows is best. It just integrates better and most LoB applications are designed for Windows. Also the Office suite is unparalleled.


2 Answers

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

like image 119
yash Avatar answered Nov 04 '22 15:11

yash


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"

like image 33
Eder Avatar answered Nov 04 '22 15:11

Eder