I want to save image that captured from following function into app asset folder.
_openGallery(BuildContext context) async{
var picture = await ImagePicker.pickImage(source: ImageSource.gallery);
this.setState((){
imageFile=picture;
});
Navigator.of(context).pop();
}
_openCamera(BuildContext context) async {
var picture = await ImagePicker.pickImage(source: ImageSource.camera);
this.setState((){
imageFile=picture;
});
Navigator.of(context).pop();
}
I've tried this code
Directory directory = await getApplicationDocumentsDirectory();
String path = directory.path;
File newImage = await _image.copy('$path');
but it gives me this error OS Error: No such file or directory, errno = 2 flutter..Can someone help with this.
try giving name to your file
Directory directory = await getApplicationDocumentsDirectory();
String path = directory.path+'/my_image.png';
File f = File(path)
f.writeAsBytes(yourImage.asBytes);