import 'package:flutter/foundation.dart';
import 'package:flutter_media_downloader/flutter_media_downloader.dart';
import 'package:hoshan/core/services/file_manager/download_file_in_web.dart';
import 'package:hoshan/core/services/permission/permission_service.dart';
import 'package:permission_handler/permission_handler.dart';

class DownloadFileService {
  static Future getFile({required final String url}) async {
    if (kIsWeb) {
      DownloadFileInWeb.downloadFromUrl(url, url.split('/').last);
      return;
    }
    await PermissionService.getPermission(permission: Permission.storage);
    await PermissionService.getPermission(permission: Permission.notification);
    MediaDownload().downloadFile(url, url.split('/').last, 'دانلود فایل',
        '/storage/emulated/0/Download}');
  }
}
