简体   繁体   English

Flutter SDK 在 MacOS 之后在 Windows 上运行应用程序后路径发生变化

[英]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.

相关问题 Flutter 将 SDK 升级到 2.2.1(最新稳定版)后更改了材质图标 - Flutter Material Icons changed after upgrading SDK to 2.2.1 (latest stable) 升级到最新的 SDK 版本 1.20.4 后,运行/调试 Flutter 应用程序的速度非常慢 - Running/Debugging Flutter app very slow after upgrading to latest SDK version 1.20.4 在 MacOS 上放置 Flutter SDK 的推荐路径是什么? - What is the recommended path to place flutter SDK on MacOS? 在 Windows 中首次安装后 Flutter 运行无响应 - Flutter running with no response after first installation in Windows Flutter 即使在代码更改后仍然运行默认的“计数器应用程序”(Windows 应用程序) - Flutter keeps running default “Counter App” even after Code change(Windows App) Flutter 应用程序在 flutter SDK 升级后无法运行 - Flutter app won't run after flutter SDK upgrade 使用 Homebrew 安装后如何获取 Flutter SDK 路径 - How to get Flutter SDK path after installing using Homebrew 运行 flutter 医生后出错:无法找到 Android SDK - Error after running flutter doctor : Unable to locate Android SDK Android sdk 文件在运行 flutter 博士后未找到 - Android sdk file not found after running flutter doctor MacOS给出zsh: command not found: 根据Flutter更新路径后flutter - MacOS gives zsh: command not found: flutter after updating path according to Flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM