[英]Flutter SDK path changed after running the app on Windows after MacOS
I have been playing around with some flutter basics on Windows then wanted to test it on Mac.我一直在 Windows 上玩一些 flutter 基础知识然后想在 Mac 上测试它。 I did successfully but when I got back again to windows to work on it again I found out that VSCode changed Flutter SDK path in the whole project.
我成功了,但是当我再次回到 windows 再次处理它时,我发现 VSCode 在整个项目中更改了 Flutter SDK 路径。 The Flutter SDK path on windows is
Flutter SDK windows上的路径是
C:\Users\USERNAME\Documents\sdk\flutter
And on Mac在 Mac 上
/Users/USERNAME/Downloads/flutter
When I tried to test it again on Windows after Mac I got so many errors like this当我在 Mac 之后尝试在 Windows 上再次测试它时,我遇到了很多这样的错误
Error: Error when reading '/Users/USERNAME/Downloads/flutter/packages/flutter/lib/material.dart': The system cannot find the path specified.
I run flutter doctor
and got this我跑了
flutter doctor
并得到了这个
When I searched for the path of Flutter SDK on Mac in the project I found this当我在项目中搜索 Mac 上 Flutter SDK 的路径时,我发现了这个
I searched for dart.flutterSdkPath
in the settings and changed the path but that didn't fix this issue我在设置中搜索了
dart.flutterSdkPath
并更改了路径,但这并没有解决这个问题
"dart.flutterSdkPath": "C:/Users/USERNAME/Documents/sdk/flutter"
so I had to use search and replace tool to replace the path of Mac to the path of Windows in all of these files.所以我不得不使用搜索和替换工具将所有这些文件中的 Mac 路径替换为 Windows 的路径。 It worked but how can I prevent changing the SDK path in the project every time I switch between Windows and Mac?
它有效,但是每次在 Windows 和 Mac 之间切换时,如何防止更改项目中的 SDK 路径?
All those file that you mentioned should be ignored already on the .gitignore
created by the flutter create command.您提到的所有这些文件都应该在 flutter 创建命令创建的
.gitignore
上被忽略。 It will be generated automatically when you build your project.它将在您构建项目时自动生成。
In case you don't have it, here is the default .gitignore
file如果你没有,这里是默认的
.gitignore
文件
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
# Web related
lib/generated_plugin_registrant.dart
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
After changing the .gitignore
files, make sure to run git rm -r --cached.
更改
.gitignore
文件后,确保运行git rm -r --cached.
before git add.
在
git add.
to ensure Git is tracking the right files.以确保 Git 正在跟踪正确的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.