How to save video recorded with camera package to gallery in Flutter?
1,594
I've managed to solve this myself.
I used gallery_saver
package to save the recorded video to gallery. Then I can delete the video file from cache using dart:io.
final video = await _cameraController.stopVideoRecording();
await GallerySaver.saveVideo(video.path);
File(video.path).deleteSync();
Author by
Admin
Updated on December 28, 2022Comments
-
Admin over 1 year
I'm using the camera package to record videos in the app. How can I save the recorded video to gallery, if it saves to the app cache directory? I'm able to get the 'XFile' but I don't really know to how to go from there.
final file = await _cameraController.stopVideoRecording(); print(file.path); // /data/user/0/com.example/cache/REC804616628562956211.mp4
Also, should I then delete it from cache after copying the file? How can I do that?