downloadData static method
Downloads a file from binary data (Uint8List) and saves it with the given filename. Works on all platforms (web, mobile, desktop).
Implementation
static Future<void> downloadData({
required Uint8List data,
required String filename,
bool saveToDocuments = false,
}) async {
if (kIsWeb) {
// Use web-specific downloader
await triggerWebDownload(data, filename);
} else {
// On native platforms, write to appropriate directory
final dir = await _getDownloadDirectory(saveToDocuments);
final file = io.File(path.join(dir.path, filename));
await file.writeAsBytes(data);
}
}