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

使用extended_image裁剪图片报错要求将ExtendedImageProvider.cacheRawData设为true

报错原因

你在代码中调用state.rawImageData获取图片原始二进制数据时,extended_image库默认不会缓存图片的原始数据,因此触发了断言校验报错。

解决方法

只需要在你加载待裁剪图片的ExtendedImage组件、或初始化ExtendedImageProvider的位置,添加cacheRawData: true配置即可,该配置必须在图片加载完成前设置才会生效。

常见场景配置示例:

  • 加载本地文件图片:
ExtendedImage.file(
  yourImageFile,
  cacheRawData: true, // 新增这行配置
  key: editorKey,
  // 保留其他原有配置
)
  • 加载网络图片:
ExtendedImage.network(
  yourImageUrl,
  cacheRawData: true, // 新增这行配置
  key: editorKey,
  // 保留其他原有配置
)
  • 加载资源图片:
ExtendedImage.asset(
  yourAssetPath,
  cacheRawData: true, // 新增这行配置
  key: editorKey,
  // 保留其他原有配置
)

配置完成后重新加载图片,再调用state.rawImageData就不会再触发该报错。

内容的提问来源于stack exchange,提问作者Gbenga B Ayannuga

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.11 11:27:02