I want to develop a flutter application where users can download all Videos from Online by one single button and store it local Device then play those videos offline on Flutter apps Using video player?
I did this by assets video. But if I use video from assets and build the application then the apk size will bigger. That's why I want to make this flutter application where users open the app and click one single button by button on pressed the list videos downloaded from the predefined server via a link in selected widgets. Then users can play those videos via video player.
You might wanna give a try to the dio package it is an http client that supports file downloading and save it locally to a given path.
Here's a code sample (source: iampawan's Github)
Future downloadFile(String url) async {
Dio dio = Dio();
try {
var dir = await getApplicationDocumentsDirectory();
await dio.download(url, "${dir.path}/myFile.txt", onProgress: (rec, total) {
print("Rec: $rec , Total: $total");
});
} catch (e) {
print(e);
}
print("Download completed");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With