SachinGanesh / screenshot

Flutter Screenshot Library
https://pub.dev/packages/screenshot
MIT License
343 stars 141 forks source link

CaptureAndSave is not working on android 10 and below #149

Closed Piyush-e7 closed 6 months ago

Piyush-e7 commented 1 year ago

CaptureAndSave is not working on Android 10 and below, but it's working fine on Android 11 and above.

I have to store screenshots in the download folder.

This is my code :

final folderDirectory = Directory("/storage/emulated/0/Download"); var data = await screenshotController.captureAndSave(folderDirectory.path, fileName: "filename.png");

This is the error:

E/flutter ( 1249): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FileSystemException: Cannot create file, path = '/storage/emulated/0/Download/Location-1688990710152985.png' (OS Error: Permission denied, errno = 13) E/flutter ( 1249): #0 _checkForErrorResponse (dart:io/common.dart:42:9) E/flutter ( 1249): #1 _File.create. (dart:io/file_impl.dart:269:7) E/flutter ( 1249): E/flutter ( 1249): #2 PlatformFilePickerWindows.saveFile (package:screenshot/src/platform_specific/file_manager/file_manager_io.dart:13:17) E/flutter ( 1249):

Please give me the solution to this.

egedib commented 9 months ago

If anyone comes here after googling this error: This issue is not related to this package, on Android 10 and below you need the WRITE_EXTERNAL_STORAGE to write to shared storage, on 10 and above, you don't need it.

ritheshSalyan commented 6 months ago

Closing issue due to inactivity. If you think it is incorrect, feel free to reoprn this issue