MacOS + VSCode multiple flutter versions

huangapple go评论77阅读模式
英文:

MacOS + VSCode multiple flutter versions

问题

我正在尝试在MacOS中拥有多个Flutter版本,具体是2.0.4和3.7.1。

我看过类似这个 https://stackoverflow.com/questions/71196386/vscode-quickly-switch-between-flutter-versions 这样的主题,并且按照这个教程 https://hackernoon.com/how-to-run-multiple-flutter-versions-on-macos-522x35ei 做了,但即使一切似乎都正确定义了,我在最新的项目中仍然被困在版本2.0.4上。

1 - 我已经永久配置了$PATH

旧版本 2.0.4

which flutter
/Users/MyUserName/Documents/flutter/bin/flutter

新版本 3.7.1

which flutter371
/Users/MyUserName/Documents/flutter_3_7_1/bin/flutter371

2 - 我已经在VSCode中配置了文件/.vscode/settings.json如下:
MacOS + VSCode multiple flutter versions

3 - 我已经直接在VSCode设置中配置了Flutter SDK paths如下:
MacOS + VSCode multiple flutter versions

然而,当我在VSCode底部导航栏中点击Flutter时,它只显示这个:
MacOS + VSCode multiple flutter versions

我做错了什么?

英文:

I'm trying to have multiple flutter versions in MacOS, namely 2.0.4 & 3.7.1.

I have seen topics like this one https://stackoverflow.com/questions/71196386/vscode-quickly-switch-between-flutter-versions and followed tutorials like this one https://hackernoon.com/how-to-run-multiple-flutter-versions-on-macos-522x35ei but even after everything seems correctly defined, I'm stuck with the version 2.0.4, in the newest project.

1 - I have configured the $PATH permanently:

Old version 2.0.4

which flutter
/Users/MyUserName/Documents/flutter/bin/flutter

New version 3.7.1

which flutter371
/Users/MyUserName/Documents/flutter_3_7_1/bin/flutter371

2 - I have configured in VSCode the file /.vscode/settings.json like such:
MacOS + VSCode multiple flutter versions

3 - I have configured directly into VSCode settings the Flutter SDK paths like such:
MacOS + VSCode multiple flutter versions

Yet, when I click the in VSCode bottom navigation bar Flutter, it only shows this:
MacOS + VSCode multiple flutter versions

What am I doing wrong?

答案1

得分: 1

这是问题所在。当 VS Code 在 dart.flutterSdkPaths 中搜索 Flutter SDK 时,它会查找 bin/flutter 二进制文件,以确保它是一个 SDK。

解决方法之一是复制该文件而不是重命名它,以便它仍然是一个有效的 Flutter SDK。但如果您想将其与另一个 SDK 混合使用,可能需要确保这些文件夹在您的 PATH 环境变量中以正确的顺序。

英文:

> Could it be that by renaming the executable to flutter371

This is the problem. When VS Code searches for a Flutter SDK in the dart.flutterSdkPaths, it looks for a bin/flutter binary to ensure it's an SDK.

One way around this be to copy the file instead of renaming it, so it's still a valid Flutter SDK. You may need to ensure these folders are in the right order in your PATH environment variable if you want to mix it with another SDK though.

huangapple
  • 本文由 发表于 2023年2月23日 23:48:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75547167.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定