Error: Type 'DecoderCallback' not found. ImageStreamCompleter load(PdfPageImageProvider key, DecoderCallback decode)
我的应用程序在 iOS 17 上失败后,我不得不做了很多升级工作,包括买了一台新的 Macbook,以便能为 iOS 17 做一个构建。结果发现,Flutter 中的 TextFormField 无法在 iOS 17 中使用自动更正功能。
因此,在升级 Macbook、XCode 和 Android Studio 后,我还有很多软件包需要更新(我的应用程序只有 2 年历史)。我现在使用 Android Studio Giraffe。由于软件包的所有更新,让我的应用程序再次运行需要相当长的时间,但现在一切都正常了。
我通常在 Windows 计算机上进行开发,因此我将所有更改复制到 Windows,将 Android Studio 升级到 Giraffe,运行 Flutter Pub Upgrade 来获取最新版本的 Flutter 和 Dart,并尝试构建,但这就是我停滞的地方。
我收到错误...
/C:/Users/me/AppData/Local/Pub/Cache/hosted/pub.dev/pdfx-2.5.0/lib/src/viewer/pdf_page_image_provider.dart:24:55: Error: Type 'DecoderCallback' not found. ImageStreamCompleter load(PdfPageImageProvider key, DecoderCallback decode) =>
^^^^^^^^^^^^^^^ /C:/Users/me/AppData/Local/Pub/Cache/hosted/pub.dev/pdfx-2.5.0/lib/src/viewer/pdf_page_image_provider.dart:40:7: Error: Type 'DecoderCallback' not found.
DecoderCallback decode) async {
^^^^^^^^^^^^^^^ /C:/Users/me/AppData/Local/Pub/Cache/hosted/pub.dev/pdfx-2.5.0/lib/src/viewer/pdf_page_image_provider.dart:24:55: Error: 'DecoderCallback' isn't a type. ImageStreamCompleter load(PdfPageImageProvider key, DecoderCallback decode) =>
^^^^^^^^^^^^^^^ /C:/Users/me/AppData/Local/Pub/Cache/hosted/pub.dev/pdfx-2.5.0/lib/src/viewer/pdf_page_image_provider.dart:40:7: Error: 'DecoderCallback' isn't a type.
DecoderCallback decode) async {
^^^^^^^^^^^^^^^ Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
* Where: Script 'E:\Dev\flutter-new\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy' line: 1350
* What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'E:\Dev\flutter-new\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s Exception: Gradle task assembleDebug failed with exit code 1
我有点进退两难,能找到的解决方法少之又少。
我的flutter doctor是...
[√] Flutter (Channel stable, 3.16.0, on Microsoft Windows [Version 10.0.22621.2715], locale en-GB)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[!] Visual Studio - develop Windows apps (Visual Studio Community 2017 15.9.48)
X Visual Studio 2019 or later is required.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its
default components
[!] Android Studio (version 2021.2)
X Unable to determine bundled Java version.
[√] Android Studio (version 2022.3)
[√] Android Studio (version 4.2)
[√] Connected device (4 available)
[√] Network resources
! Doctor found issues in 2 categories.
我不是为Windows编写的,所以不需要VS2019的原因。我安装了 Java 版本 8。
当我尝试使用 AGP 升级助手升级 Gradle 时...没有任何反应。
我不知道还能从哪里找到摆脱困境的办法。
目前,由于 flutter 升级到 3.16 版本,pdfx 包出现问题,如本问题 https: //github.com/ScerIO/packages.flutter/issues/448所述。
有一种临时方法可以解决这个问题,即把 pubspec.yaml 中的 pdfx 软件包从
pdfx: ^2.4.0
改为
pdfx:
git:
url: 'https://github.com/ScerIO/packages.flutter'
ref: '4be9de9ffed5398fd7d5f44bbb07dcd3d3f1711b'
path: packages/pdfx
我通过运行以下命令更新我使用的软件包的版本解决了这个问题:
flutter pub upgrade;
在这种情况下,运行上述命令后,您可以运行以下命令:
flutter pub upgrade --major-versions;
现在您可以生成构建或应用程序包。这就是我解决这个问题的方法。