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

运行StreamChat Flutter示例时出现编译错误求助

StreamChat Flutter示例运行编译错误解决方案

问题描述

运行StreamChat Flutter示例时出现编译失败,所有依赖及Flutter均已更新,错误日志如下:

Get java version from JAVA_HOME: C:\Program Files\Android\Android Studio1\jbr
The photo_manager java version is 17
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/photo_manager-2.8.1/lib/src/internal/image_provider.dart:71:5: Error: Type 'DecoderCallback' not found.
    DecoderCallback decode, // ignore: deprecated_member_use
    ^^^^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/photo_manager-2.8.1/lib/src/internal/image_provider.dart:96:5: Error: Type 'DecoderCallback' not found.
    DecoderCallback decode, // ignore: deprecated_member_use
    ^^^^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/photo_manager-2.8.1/lib/src/internal/image_provider.dart:71:5: Error: 'DecoderCallback' isn't a type.
    DecoderCallback decode, // ignore: deprecated_member_use
    ^^^^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/photo_manager-2.8.1/lib/src/internal/image_provider.dart:96:5: Error: 'DecoderCallback' isn't a type.
    DecoderCallback decode, // ignore: deprecated_member_use
    ^^^^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/stream_chat_flutter-7.0.2/lib/src/bottom_sheets/stream_channel_info_bottom_sheet.dart:324:1: Error: Expected 0 type arguments.
PersistentBottomSheetController<T> showChannelInfoBottomSheet<T>({
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/stream_chat_flutter-7.0.2/lib/src/bottom_sheets/stream_channel_info_bottom_sheet.dart:339:5: Error: Expected 0 type arguments.
    showBottomSheet<T>(
    ^
/C:/TPA%20Mobile%20App/flutter/packages/flutter/lib/src/material/bottom_sheet.dart:1327:33: Context: Found this candidate, but the arguments don't match.
PersistentBottomSheetController showBottomSheet({
                                ^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception


FAILURE: Build failed with an exception.

* Where:
Script 'C:\TPA Mobile App\flutter\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy' line: 1419

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\TPA Mobile App\flutter\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 8s
Error: Gradle task assembleDebug failed with exit code 1

错误原因

  1. photo_manager 2.8.1版本过旧:依赖已被Flutter移除的DecoderCallback类型,导致类型未找到错误。
  2. stream_chat_flutter 7.0.2版本不兼容新版Flutter:新版Flutter中showBottomSheet API已移除泛型参数,该版本仍在使用泛型调用,参数不匹配。

解决步骤

1. 升级photo_manager依赖

在项目的pubspec.yaml文件中,将photo_manager指定为兼容新版Flutter的版本(如2.8.2及以上):

dependencies:
  photo_manager: ^2.8.2

执行命令更新依赖:

flutter pub get

2. 升级stream_chat_flutter依赖

同样在pubspec.yaml中升级stream_chat_flutter到支持新版Flutter的版本(如7.1.0及以上):

dependencies:
  stream_chat_flutter: ^7.1.0

执行命令更新:

flutter pub get

3. 清理缓存并重新构建

若更新后仍报错,清理Flutter缓存并重新构建项目:

flutter clean
flutter pub get
flutter run

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 08:03:23