Flutter - 为什么我的应用程序中有一个 windows 文件夹?

Flutter - Why is there a windows folder in my app?

我的 Flutter 应用程序中有一个名为 windows 的文件夹。它还会导致某些 C++ 和其他文件出现在源代码管理更改中。

如果我不是为 windows 开发,删除这个文件夹是否安全?它为什么以及如何到达那里?

创建它是因为它被列为 flutter create 命令的默认平台之一:

% flutter --help create

...

    --platforms              The platforms supported by this project. Platform folders (e.g. android/) will be generated
                             in the target project. This argument only works when "--template" is set to app or plugin.
                             When adding platforms to a plugin project, the pubspec.yaml will be updated with the
                             requested platform. Adding desktop platforms requires the corresponding desktop config
                             setting to be enabled.
                             [ios (default), android (default), windows (default), linux (default), macos (default), web
                             (default)]
...

如果您想为 Windows 构建应用程序,它就在那里。

是的,您可以安全地删除它。

如果你后悔删除它并想重新创建它,你可以在你的项目文件夹中写上flutter create .

如果您不想在下一个项目中使用它,您可以在创建项目时指定要支持的平台:

flutter create --platforms ios,android my_new_project

您的项目可用于 windows 应用程序,这就是为什么您的项目目录中有 window 文件夹。 如果删除它,您将无法 运行 在 windows 上提交您的申请。