downloadWithProgress static method
Implementation
static Future<Uint8List?> downloadWithProgress(String url) async {
if (isYoutubeUrl(url)) {
ModernFormProgressDialog progressDialog = ModernFormProgressDialog();
var stream = BehaviorSubject<double>.seeded(0.0);
var streamText =
BehaviorSubject<String>.seeded('Fazendo download do arquivo...');
progressDialog.showProgressDialog(
streamValue: stream,
streamText: streamText,
progressColor: Colors.white,
barrierColor: Color(0x88222222),
);
Uint8List? bytes = await downloadFromYoutube(
url,
(totalByteCount, bytesTransferred) {
double percent = 0;
percent = bytesTransferred / totalByteCount;
stream.add(percent);
streamText.add("${(percent * 100).toStringAsFixed(2)}% concluĂdo...");
},
true,
);
stream.close();
streamText.close();
progressDialog.dismissProgressDialog();
return bytes;
} else {
return ModernFormDownloadHelper.downloadWithProgress(url);
}
}