The function getExternalStorageDirectory() and ApplicationDocumentDirectory() gives the same directory to me that is inside the android folder. I like to create a folder in storage/emulated/0 , i tried explicitly creating it with Directory('storage/emulated/0').create(); then it says you have no permission. And i gave all the possible permissions and still gets the same result. Is there any way to create a folder in storage/emulated/0 ?
NB: _getPermission returns a bool according to the permission status. This code works well in an emulator but it is not working in an actual device.
takePhoto(BuildContext context) async {
if ( await _getPermission(Permission.manageExternalStorage)){
final image =await picker.pickImage(source: ImageSource.camera);
var newPath = "storage/emulated/0/takephotosaver";
var directory = Directory(newPath).create();
File fileIMage = File(image!.path);
var imageName = DateTime.now().toString();
fileIMage.copy("$newPath/$imageName.jpg");
Navigator.push(context, MaterialPageRoute(builder: (context)=>MyPreview(fileIMage)));
}
} }
Edit :- This code is working in android version 9 and below but not working in android 10 and 11. Is there a way to display the image taken by my camera in a separate folder?