【问题标题】:Unable to read Image: error: A value of type 'Future<PickedFile>' can't be assigned to a variable of type 'File'无法读取图像:错误:“Future<PickedFile>”类型的值不能分配给“文件”类型的变量
【发布时间】:2021-06-19 12:11:17
【问题描述】:
300: pickImage() async {
301:    final ImagePicker _picker = ImagePicker();
302:    final image = _picker.getImage(source: ImageSource.camera);
303:    if (image == null) return null;
304:    setState(() {
305:      _loading = true;
306:      _image = image;
307:    });
308:    classifyImage(image);
309:  }

在以下位置引发错误:

  • 306:错误:无法将“Future”类型的值分配给“File”类型的变量。
  • 308:错误:无法将参数类型“Future”分配给参数类型“文件”。

我在main.dart 前面添加了// @dart=2.9 。

我是 Flutter-Tflite 的新手,有人可以提供指导吗?

【问题讨论】:

    标签: flutter dart tensorflow-lite


    【解决方案1】:

    这是因为它是一个异步函数,因此您必须使用“等待”。

    final image = await _picker.getImage(source: ImageSource.camera);

    【讨论】:

      猜你喜欢
      • 2020-01-21
      • 1970-01-01
      • 2021-08-29
      • 1970-01-01
      • 2023-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多