在颤振中使用相机包没有点击图片和预览

时间:2021-02-17 12:50:08

标签: flutter dart flutter-dependencies

我使用的相机包是: 相机: 吉特: 网址:https://github.com/flutter/plugins.git 路径:包/相机/相机 参考:cfa709835ab85702ee8a9ed24bbe7a3fe736c3f5

code 是:

try {
     final path =
      join((await getTemporaryDirectory()).path, '${DateTime.now()}.png');
      await controller.takePicture(**path**); 
       Navigator.push(
        context,
         MaterialPageRoute(
          builder: (context) => PreviewScreen(
           imgPath: path,
                   )),
                 );

相同的代码在不同的项目中运行良好,但每当我将其实施到现有项目时,都会得到 error

Too many positional arguments: 0 expected, but 1 found.  Try removing the extra argument.

在代码的第 4 行,粗体文本 *path

当我从那里删除 **path 时, 触发函数后的控制台输出为:

 console output: I/flutter (13243): Error:Previous capture has not returned yet.
I/flutter (13243): Error message : takePicture was called before the previous capture returned.
I/flutter (13243): Error:Previous capture has not returned yet.
I/flutter (13243): Error message : takePicture was called before the previous capture returned.

请帮忙。 抱歉我的英语不好。

1 个答案:

答案 0 :(得分:0)

从 0.6.x 版本开始,takePicture 没有参数。如果您想使用最新的插件版本运行它,请查看当前示例。

refer了解更多信息。