将照相机图片保存到摇摆的相机卷

发布于 2025-02-08 09:32:11 字数 753 浏览 2 评论 0 原文

    final testDir =
        await Directory('${extDir.path}/test').create(recursive: true);
    final String filePath = '${testDir.path}/${DateTime.now().millisecondsSinceEpoch}.jpg';
    await pictureController.takePicture(filePath);


    final file = File(filePath);
    print("==> hastakePhoto : ${file.exists()} | path : $filePath");
    final img = imgUtils.decodeImage(file.readAsBytesSync());
    print("==> img.width : ${img?.width} | img.height : ${img?.height}");
    print("----------------------------------");```





I am using Camerawesome package to take a picture, image were successfully taken but it isnt saved in the device. Any ideas please? All permissions were granted
    final testDir =
        await Directory('${extDir.path}/test').create(recursive: true);
    final String filePath = '${testDir.path}/${DateTime.now().millisecondsSinceEpoch}.jpg';
    await pictureController.takePicture(filePath);


    final file = File(filePath);
    print("==> hastakePhoto : ${file.exists()} | path : $filePath");
    final img = imgUtils.decodeImage(file.readAsBytesSync());
    print("==> img.width : ${img?.width} | img.height : ${img?.height}");
    print("----------------------------------");```





I am using Camerawesome package to take a picture, image were successfully taken but it isnt saved in the device. Any ideas please? All permissions were granted

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

偏闹i 2025-02-15 09:32:11

您的问题有多种解决方案。

第一个方法:

您可以使用许多可用软件包之一:
这将是Gallery Saver的示例集成 https://pub.dev/packages/packages/gallery_saver

final testDir = await Directory('${extDir.path}/test').create(recursive: true);
final String filePath = '${testDir.path}/${DateTime.now().millisecondsSinceEpoch}.jpg';
await pictureController.takePicture(filePath);


final file = File(filePath);
print("==> hastakePhoto : ${file.exists()} | path : $filePath");
final img = imgUtils.decodeImage(file.readAsBytesSync());
print("==> img.width : ${img?.width} | img.height : ${img?.height}");
print("----------------------------------");

//Gallery saver code
await GallerySaver.saveImage(filePath);

>第二种方法:

使用路径提供商

final String path = await getApplicationDocumentsDirectory().path;
await file.copy('$path/yourname.jpg');

There are multiple Solutions to your problem.

First method:

You can use one of the many available packages:
This would be an example integration for gallery saver https://pub.dev/packages/gallery_saver

final testDir = await Directory('${extDir.path}/test').create(recursive: true);
final String filePath = '${testDir.path}/${DateTime.now().millisecondsSinceEpoch}.jpg';
await pictureController.takePicture(filePath);


final file = File(filePath);
print("==> hastakePhoto : ${file.exists()} | path : $filePath");
final img = imgUtils.decodeImage(file.readAsBytesSync());
print("==> img.width : ${img?.width} | img.height : ${img?.height}");
print("----------------------------------");

//Gallery saver code
await GallerySaver.saveImage(filePath);

Second Method:

Using Path Provider https://pub.dev/documentation/path_provider/latest/path_provider/getApplicationDocumentsDirectory.html

final String path = await getApplicationDocumentsDirectory().path;
await file.copy('$path/yourname.jpg');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文