[英]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我只是为 Windows 安装所有东西?
由于没有提供官方方法,我尝试了多种方法来将 Flutter 与 WSL 一起使用。
我面临的限制:
我总是更喜欢在 Windows 上安装东西并在 WSL 上运行它们。 我只是稍微修改了命令,现在效果很好。 我在.bashrc
添加了以下内容:
alias winpro='cd /mnt/<DIRECTORY IN WINDOWS YOU WANT>'
flutter() {
command CMD.exe /c flutter $@
}
现在您可以使用 winpro 切换到 windows,flutter 将在 WSL 中照常工作。
(详细: https : //www.yashlamba.com/blogs/1/ )
您可以在 WSL 中设置 Flutter 并使用 VS Code Remote-WSL(在 Windows 上)进行开发,同时在 WSL 中安装 Dart Core 扩展
https://dnmc.in/2021/01/25/setting-up-flutter-natively-with-wsl2-vs-code-hot-reload/
您可以在 .bashrc 中创建这样的别名:
alias flutter='cmd.exe /c flutter'
那么您应该能够直接从 bash 使用所有 flutter 命令。
我尝试在本教程中使用 flutter 和 WSL。
我遇到的问题:出于某种原因,“从 WSL1 shell 调用 Windows Flutter”中指定的脚本给我错误。
我遵循的解决方法:正如@0xManjeet 在他的回答中提到的那样,我没有运行脚本而是创建了别名
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.