【问题标题】:Image picker scanned to null图像选择器扫描为空
【发布时间】:2020-11-07 16:26:41
【问题描述】:
File _image;
    final picker = ImagePicker();

    Future getImage() async {
      final pickedFile = await picker.getImage(source: ImageSource.camera);

      setState(() {
        if (pickedFile != null) {
          _image = File(pickedFile.path);
        } else {
          print('No image selected.');
        }
      });
    }

输出:

D/MediaScannerConnection(16161):已扫描 /storage/emulated/0/Android/data/com.xxxx.xxxx/files/Pictures/9d9ed6a1-292c-428a-bf24-38ea1a58742c6940060118053310767.jpg 为空

【问题讨论】:

  • 你解决了吗?

标签: flutter dart imagepicker


【解决方案1】:

我也遇到过这个问题。我发现由于MainActivityimage_picker 完成后被杀死,捕获的图像数据以某种方式丢失。要解决这个问题,只需添加检索丢失的数据处理程序。您可以在文档here 中找到示例代码。 (参考部分:在Android上处理MainActivity销毁#)

【讨论】:

    猜你喜欢
    • 2021-12-02
    • 1970-01-01
    • 1970-01-01
    • 2015-11-22
    • 2023-01-29
    • 2016-08-10
    • 1970-01-01
    • 2016-09-08
    • 2011-05-08
    相关资源
    最近更新 更多