import 'dart:io'; import 'package:flutter/services.dart'; const MethodChannel _downloadsChannel = MethodChannel('nhance/downloads'); Future androidSdkInt() async { if (!Platform.isAndroid) return null; try { final sdkInt = await _downloadsChannel.invokeMethod('getSdkInt'); return sdkInt; } catch (_) { return null; } } Future savePdfToAndroidDownloads({ required String fileName, required List bytes, }) async { final savedPath = await _downloadsChannel.invokeMethod( 'saveToDownloads', { 'fileName': fileName, 'bytes': bytes, }, ); if (savedPath == null || savedPath.isEmpty) { throw const FileSystemException('Unable to save file to Downloads'); } return savedPath; } Future openAndroidDownloadedFile(String path) async { await _downloadsChannel.invokeMethod('openFile', {'path': path}); }