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?.
I tried multiple ways to use flutter with WSL as there is no official way provided.
Restrictions I faced:
- Couldn't run the projects stored on WSL.
- 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/)
Flutter - Windows
Android Studio + Emulators - Windows
Execute on bash:
cmd.exe /c flutter run
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.
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/
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
© 2022 - 2024 — McMap. All rights reserved.