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

Flutter升级后Windows编译报错:DecoderCallback类型未找到

解决Flutter 3.16.0 + pdfx-2.5.0在Windows端的DecoderCallback编译错误
  • 升级pdfx依赖包
    Flutter 3.16.0对依赖的image库做了版本更新,pdfx-2.5.0的适配性不足导致类型缺失。执行以下命令升级到兼容版本:

    flutter pub upgrade pdfx
    

    或者直接在pubspec.yaml中指定pdfx的最新稳定版(如pdfx: ^3.0.0),再执行flutter pub get。

  • 手动修复DecoderCallback引用(临时方案)
    若暂时无法升级pdfx,可修改报错的pdf_page_image_provider.dart文件:

    1. 定位到DecoderCallback报错的代码行
    2. 将DecoderCallback替换为ImageDecoderCallback
    3. 检查导入语句,确保引入了正确的依赖(如import 'package:flutter/src/painting/image_decoder.dart';或对应image库的导入)
  • 清理构建缓存并重新编译
    执行以下命令清除旧缓存并重建:

    flutter clean
    del pubspec.lock
    flutter pub get
    gradlew.bat assembleDebug
    
  • 修复环境潜在问题

    • 升级Visual Studio到2019及以上版本,解决Windows开发环境的版本过低问题
    • 在Android Studio Giraffe中设置正确的JDK路径(推荐JDK 17):依次打开File > Project Structure > SDK Location,指定JDK的安装目录

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.05 15:25:57