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

Flutter在Chrome中无法调试,image_picker相关编译错误求助

问题描述

在Chrome网页端调试Flutter应用时,出现编译错误:

/C:/Users/Lenovo/AppData/Local/Pub/Cache/hosted/pub.dev/image_picker_platform_interface-2.9.2/lib/src/types/picked_file/html.dart:30:38: Error: The method 'UnmodifiableUint8ListView' isn't defined for the class 'PickedFile'.
 - 'PickedFile' is from 'package:image_picker_platform_interface/src/types/picked_file/html.dart' ('/C:/Users/Lenovo/AppData/Local/Pub/Cache/hosted/pub.dev/image_picker_platform_interface-2.9.2/lib/src/types/picked_file/html.dart').
Try correcting the name to the name of an existing method, or defining a method named 'UnmodifiableUint8ListView'.
      return Future<Uint8List>.value(UnmodifiableUint8ListView(_initBytes!));
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^
Failed to compile application.

Exited (1).

当前pubspec.yaml依赖:

cupertino_icons: ^1.0.2
flutter_face_api: ^5.2.1
google_mlkit_face_detection: ^0.8.0
image_picker: ^1.0.4
firebase_core: ^2.17.0
cloud_firestore: ^4.9.3
uuid: ^4.1.0
fluttertoast: ^8.2.2
material_design_icons_flutter: 7.0.7296
解决方法
  • 升级image_picker依赖:将image_picker: ^1.0.4替换为最新稳定版本(如^1.0.7及以上),新版本已修复web端该编译问题。修改后执行flutter pub get更新依赖。
  • 指定image_picker_platform_interface版本:若无法升级image_picker主包,可在pubspec.yaml中直接指定更高版本的平台接口依赖:
    dependencies:
      # 其他依赖保持不变
      image_picker_platform_interface: ^2.10.0
    
    执行flutter pub get即可,该版本已修复UnmodifiableUint8ListView的引用问题。
  • 清理缓存重新拉取依赖:若升级后问题仍存在,执行以下命令清理本地缓存后重新获取依赖:
    flutter pub cache clean
    flutter pub get
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 23:50:00