颤振图像压缩总是给出错误名称.在null时调用toLowerCase



这是我正在使用的代码。我用不同的文件格式检查了它,但仍然显示同样的错误,我检查了"img.path"它显示了图像的路径。我不明白为什么我得到一个错误。

String targetPath;
var result = await FlutterImageCompress.compressAndGetFile(
img.path,
targetPath,
quality: 88,
format: CompressFormat.webp,
);

Error I am getting:

[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: The method 'toLowerCase' was called on null.
Receiver: null
Tried calling: toLowerCase()
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      Validator.checkFileNameAndFormat
package:flutter_image_compress/src/validator.dart:19
#2      FlutterImageCompress.compressAndGetFile
package:flutter_image_compress/flutter_image_compress.dart:150
#3      _AddImageState.uploadFile
package:softclaw/…/addpost/addimage.dart:225
#4      _AddImageState.build.<anonymous closure>
package:softclaw/…/addpost/addimage.dart:97
<asynchronous suspension>

targetPath是通过checkFileNameAndFormat>因此,检查以确保它不为空。

相关内容

  • 没有找到相关文章

最新更新