I am trying to make a flutter app with downloading videos functionality from a url and videos are expected to be large (1 to 2 hours of 720p atleast).
I used Dio for this but it tries to store the complete video in RAM which causes the out of memory error. This is the code I used.
Any workarounds? or better solutions?
Dio dio = Dio();
dio
.download(
url,
filePathAndName,
onReceiveProgress: (count, total) {
progressStream.add(count / total);
},
)
.asStream()
.listen((event) {
})
.onDone(() {
Fluttertoast.showToast(msg: "Video downloaded");
});
After a while it gives this exception : java.lang.OutOfMemoryError