flutter - 错误 image_picker: 类型 (null) 不支持压缩。以原始质量返回图像
问题描述
我想通过image_picker获取图片,但我的项目出现错误。请告诉我解决方案。
错误↓</p>
image_picker: compressing is not supported for type (null). Returning the image with original quality
flutter: /private/var/mobile/Containers/Data/Application/~~~~/tmp/image_picker_~~~~.jpg
我的项目代码
import 'package:flutter/material.dart';
import 'dart:io';
import 'package:image_picker/image_picker.dart';
File? _image;
final picker = ImagePicker();
XFile? pickedFile = await picker.pickImage(source: ImageSource.gallery);
Future _getImage() async {
setState(() {
if (pickedFile != null) {
print("${pickedFile.path}");
_image = File(pickedFile.path);
}else{
print("NO IMAGE");
}
_image = File(pickedFile!.path);
});
}
解决方案
推荐阅读
- java - Android Studio:java.lang.RuntimeException:无法启动活动组件信息
- reactjs - React Router Redirect 和 useEffect 内存泄漏
- datetime - 没有日期时间同步的服务器上的 InfluxDB 和 Grafana
- vue.js - 没有根元素的 Vue
- java - React Native Android 原生模块在调试时运行良好,但在发布时无法运行
- python - Python:在奇怪的情况下“没有名为 [] 的模块”
- mysql - 在SQL中,查询越短,运行越快是真的吗
- ruby-on-rails - 在运行 Rails ActiveRecord 聚合方法时,是否有一种优雅的方式来使用应用程序时区?
- c++ - 返回一个指针数组
- node.js - ValidationError 未被快速错误处理程序捕获