简体   繁体   中英

Using camera package in flutter not getting picture clicked and preview

The camera package I am using is: camera: git: url: https://github.com/flutter/plugins.git path: packages/camera/camera ref: cfa709835ab85702ee8a9ed24bbe7a3fe736c3f5

The code is:

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

Same code is working fine in different project but whenever I am implementing it to existing one getting error :

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

on line number 4 of code, the bold text * path

When I am removing the **path from there, The console output after triggering function is:

 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.

Please help. Sorry for my bad English.

Since version 0.6.x takePicture has no parameter. If you want to run it with the latest plugin version, take a look at the current example.

Please, refer for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM