downloadFile static method
hàm này để download file vào thư mục download trong thiết bị
Implementation
static Future<void> downloadFile(Uint8List? data, String? fileName) async {
/// nếu không có data, fileName thì không làm gì cả
if (data == null || fileName.isNullOrEmpty) return;
/// thực hiện lưu file vào thư mục download
String savePath = "$_downloadDirectory$fileName";
try {
final file = File(savePath);
await file.writeAsBytes(data);
} catch (e, stackTrace) {
ErrorReporter.log(e, stackTrace);
rethrow;
}
}