You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter Windows从桌面图库选图触发MissingPluginException报错求助

解决Flutter Windows应用中image_picker的MissingPluginException问题

以下是针对性的解决步骤:

  • 确认image_picker版本支持Windows平台
    打开项目的pubspec.yaml文件,确保使用的image_picker版本不低于0.8.4(该版本开始正式支持Windows),推荐使用最新稳定版,示例配置:

    dependencies:
      flutter:
        sdk: flutter
      image_picker: ^1.0.7
    
  • 更新并同步依赖
    在终端执行flutter pub get,确保依赖包正确拉取并完成平台配置。

  • 清理并重建Windows项目
    执行flutter clean清除旧的构建缓存,再运行flutter build windows重新生成Windows平台的构建文件,之后启动项目测试。

  • 手动注册插件(若上述步骤无效)
    打开windows/runner/main.cpp,先添加头文件引用:

    #include <image_picker_windows/image_picker_windows.h>
    

    然后在插件注册区域添加:

    ImagePickerWindowsRegisterWithRegistrar(registrar);
    

    注:新版本Flutter插件通常会自动完成注册,此步骤仅作为兜底方案。

  • 配置Windows图片访问权限
    若应用无法访问图库,需在windows/runner/Runner.rc或MSIX打包的Package.appxmanifest中添加图片库访问权限声明,示例:

    <capability name="picturesLibrary" />

内容的提问来源于stack exchange,提问作者Soton

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 15:15:35