模块模板不支持“--platforms”参数

问题描述 投票:0回答:1

当我尝试在 Windows 上运行在 VSCode 中创建的全新 Flutter 项目时,会抛出上述错误。详细重现步骤如下:

  1. 我在 VSCode 中创建了一个新的默认 Flutter 应用程序。
  2. 我跑了
    flutter config --enable-windows-desktop
  3. 我跑了
    flutter devices

Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19043.1766] Chrome (web)      • chrome  • web-javascript • Google Chrome 103.0.5060.66 Edge (web)        • edge    • web-javascript • Microsoft Edge 103.0.1264.44

  1. 我在 Vscode 中运行了该应用程序,没有进行调试,并选择了

    Enable Windows for this Project
    。 它报告了以下错误。

    flutter create --platforms windows . The "--platforms" argument is not supported in module template. exit code 2

  2. flutter doctor
    输出:

Doctor 摘要(要查看所有详细信息,请运行 flutter doctor -v):

[√] Flutter(通道稳定,3.0.4,在 Microsoft Windows [版本 10.0.19043.1766],区域设置 en-GB)

[√] Android 工具链 - 为 Android 设备开发(Android SDK 版本 30.0.3)

[√] Chrome - 网络开发

[√] Visual Studio - 为 Windows 开发(Visual Studio Community 2022 17.0.6)

[√] Android Studio(4.2 版)

[√] VS Code(版本1.68.1)

[√]已连接设备(3个可用)

[√] HTTP 主机可用性

• 未发现问题!

编辑:我从命令行重新创建了应用程序,它运行没有问题。看起来无论问题是什么,它都来自 VSCode

flutter visual-studio-code flutter-desktop
1个回答
0
投票

我现有的包也有同样的问题,并在 github 上发现了这个问题 包模板不支持“--platforms”参数。 #5252。 他们删除了此选项,现在要添加对现有包的支持,您需要根据此官方文档更新您的 pubspec.yaml 文件。

flutter:
  plugin:
    platforms:
      android:
        package: com.example.hello
        pluginClass: HelloPlugin
      ios:
        pluginClass: HelloPlugin

创建包的命令

flutter create --org com.example --template=plugin --platforms=android,ios,linux,macos,windows -a kotlin hello
© www.soinside.com 2019 - 2024. All rights reserved.