首页 > 解决方案 > 错误 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);
      });
    }

标签: flutterimagepicker

解决方案


推荐阅读