我刚把我的Macbook设置为扑动显影,

所以我下载了flutter SDK,并把它放在我的文档中。之后,我在命令行中设置了path变量来使用flutter。

我执行命令flutter create todolist,这样我就实现了一个空白项目。

我还用Dart-Code设置了我的visual studio代码,这样我就有了正确的语法高亮,智能感知等。

所以当我打开visual studio代码时,它会突出显示导入方法,如下图所示:

这意味着它还会突出显示正确的类,从而完全难以理解它是否是一个真正的错误。

我已经执行了pub get和flutter包get,并正确地得到了所有内容。 我的路径变量都是正确的。

为什么它突出显示它无法找到“导入”包?


当前回答

Warning! This package referenced a Flutter repository via the .packages file that is no longer available. The repository from which the 'flutter' tool is currently executing will be used instead. running Flutter tool: /opt/flutter previous reference : /Users/Shared/Library/flutter This can happen if you deleted or moved your copy of the Flutter repository, or if it was on a volume that is no longer mounted or has been mounted at a different location. Please check your system path to verify that you are running the expected version (run 'flutter --version' to see which flutter is on your path).

检查flutter包的输出可以发现,在我的案例中,原因是由于移动了flutter sdk。

其他回答

打开命令面板(ctrl+shift+p),输入flutter: get packages(应该自动完成);在它解决后,再次打开命令面板并键入reload window并执行该命令。这样可以尽快解决问题。

让Dart-Code可靠地找到您的Flutter安装和使用它的最快方法是创建一个新的FLUTTER_ROOT环境变量,并将其设置为您的Flutter路径。

运行flutter pub add firebase_core命令

最重要的是-进入您的flutter安装目录,检查是否有Flutter_core,如果没有,运行flutter pub add firebase_core

如果它不是固定的,仍然尝试这些所提到的到处

颤振酒吧得到 重新启动Visual Studio Code或Android Studio

Warning! This package referenced a Flutter repository via the .packages file that is no longer available. The repository from which the 'flutter' tool is currently executing will be used instead. running Flutter tool: /opt/flutter previous reference : /Users/Shared/Library/flutter This can happen if you deleted or moved your copy of the Flutter repository, or if it was on a volume that is no longer mounted or has been mounted at a different location. Please check your system path to verify that you are running the expected version (run 'flutter --version' to see which flutter is on your path).

检查flutter包的输出可以发现,在我的案例中,原因是由于移动了flutter sdk。

如果你已经使用了flutter packages get命令,错误仍然存在,你可以简单地重新加载VS code Developer: reload Window命令。简单地输入后按Ctrl+Shift+P (Cmd+Shift+P Mac用户)。它将清除错误。这就像刷新VS Code一样。