패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.2.0

downloadsfolder

다양한 플랫폼에서 파일 다운로드 관련 작업을 수행하고 다운로드 폴더 경로를 검색하기 위한 Flutter 플러그인입니다.

AndroidiOSmacOSWindows
30일 다운로드
1.8만
좋아요
53
Pub 점수
150

패키지 설치

flutter pub add downloadsfolder

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

downloadsfolder 패키지는 플러터 플러그인으로 장치의 다운로드 폴더에 대한 크로스플랫폼 액세스를 제공합니다. 이는 앱이 다운로드 디렉터리의 경로를 가져오고 해당 위치에서 파일 저장 또는 읽기와 같은 파일 작업을 수행할 수 있도록 합니다. Android, iOS, macOS 및 Windows와 호환되며, 플랫폼별 로직을 추상화함으로써 다양한 운영 체제에서 다운로드 처리를 간소화합니다. 신뢰성 있고 일관된 방식으로 다운로드된 파일을 관리해야 하는 앱에 적합합니다.

사용 사례

  • 사용자가 다운로드한 파일 저장
  • 다운로드된 콘텐츠에 프로그래밍 방식으로 액세스
  • 크로스 플랫폼 파일 관리
  • 다운로드 관리자와의 통합
  • 앱에서 생성한 다운로드 처리

주요 기능

  • 플랫폼에 관계없는 다운로드 경로 검색
  • Android, iOS, macOS 및 Windows 지원
  • 파일 작업을 위한 간단한 API
  • 다양한 플랫폼 간의 일관된 동작
  • 경량이며 통합이 쉬움

적합한 대상

  • 파일 관리 앱
  • 미디어 또는 문서 뷰어
  • 다운로드 유틸리티
  • 지속 저장이 필요한 앱
  • 다중 플랫폼을 대상으로 하는 개발자

고려 사항

  • 일부 플랫폼에서는 권한이 필요할 수 있습니다
  • iOS는 Info.plist에서 올바른 구성이 필요합니다
  • 운영 체제 버전에 따라 동작이 약간 다를 수 있습니다
  • 대규모 파일 시스템 조작을 위한 것이 아님
  • 다운로드 폴더 범위에 한정

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Flutter Download Folder Plugin

A Flutter plugin for retrieving the path to the downloads folder and performing operations related to file downloads on different platforms.

Support

Android iOS Windows macOS Linux
Support SDK 19+ iOS 12+ ✅ ✅ ✅

How it works?

The Flutter Download Folder plugin provides a simple interface to interact with the downloads folder on various platforms. Here's a brief overview of how the main functionalities work:

Get Download Directory

getDownloadDirectory() returns a Directory pointing at the platform's downloads location. On Android this is Environment.DIRECTORY_DOWNLOADS; on iOS it is the app's documents directory; on the desktop platforms it is the OS-provided downloads folder.

Copy File into Download Folder

copyFileIntoDownloadFolder(...) copies a file into the downloads folder, ensuring a unique name to avoid overwriting existing files. Optional knobs:

  • subDirectoryPath — drop the file into a sub-folder of Downloads (e.g. "Reports"); missing intermediate directories are created automatically.
  • openAfterSave — when true, the saved file is opened in the OS default viewer immediately after the copy.

On Android 10+ (API 29+) the file is saved via MediaStore so the plugin does not require MANAGE_EXTERNAL_STORAGE. It returns a SavedDownload? exposing both the on-disk file and (on Android 10+ only) the MediaStore contentUri; see the scoped-storage note below. Returns null if the save failed.

Open Download Folder

openDownloadFolder() opens the download folder in the system file browser. On Android and iOS this goes through a platform channel; on Windows/macOS/Linux it shells out to the appropriate native command.

Installation

To use this plugin, add downloadsfolder as a dependency in your pubspec.yaml file:

dependencies:
  downloadsfolder: ^2.0.0-pre.2

Setup

Android
  • The copyFileIntoDownloadFolder method uses a workaround on Android 29 and higher to avoid using MANAGE_EXTERNAL_STORAGE.
    • On Android devices with API 29 and higher, the method saves the file using MediaStore to bypass restrictions.
    • On Android devices with API 28 and lower, ensure that you have added the WRITE_EXTERNAL_STORAGE permission to your AndroidManifest.xml file under the <application> element.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
iOS
  • To enable the openDownloadFolder function on iOS, you must add the UISupportsDocumentBrowser key to your Info.plist. Without it, iOS will refuse to resolve the shareddocuments:// URL the plugin opens and openDownloadFolder will return false.
<key>UISupportsDocumentBrowser</key>
<true/>
macOS

Go to your project folder, macOS/Runner/DebugProfile.entitlements

For release you need to open 'YOUR_PROJECT_NAME'Profile.entitlements

and add the following key:

<key>com.apple.security.files.downloads.read-write</key>
<true/>

Usage

Get Download Directory
import 'package:downloadsfolder/downloadsfolder.dart';

void main() async {
  try {
    final Directory downloadDirectory = await getDownloadDirectory();
    print('Downloads folder path: ${downloadDirectory.path}');
  } catch (e) {
    print('Failed to retrieve downloads folder path $e');
  }
}
Copy File into Download Folder
import 'package:downloadsfolder/downloadsfolder.dart';

void main() async {
  final String filePath = '/path/to/source/file.txt';
  final String fileName = 'copied_file.txt';

  final SavedDownload? saved = await copyFileIntoDownloadFolder(
    filePath,
    fileName,
    subDirectoryPath: 'Reports', // optional — saves under /Download/Reports
    openAfterSave: true,         // optional — pops the file in the OS default viewer
  );
  if (saved != null) {
    print('File saved at: ${saved.file.path}');
    if (saved.contentUri != null) {
      // Android 10+: use this URI for read/share/intent work.
      print('MediaStore URI: ${saved.contentUri}');
    }
  } else {
    print('Failed to copy file.');
  }
}

Android 10+ note (scoped storage). The SavedDownload.file path is real — the file genuinely lives at that location and any file-manager app can see it. However, due to Android's scoped storage rules, your own app generally cannot read or write that path back via plain dart:io once the save is complete. Use SavedDownload.contentUri for any subsequent work (sharing through share_plus, opening with an ACTION_VIEW intent, reading bytes via ContentResolver, etc.). On Android < 10, iOS, and the desktop platforms, file is directly usable with dart:io and contentUri is null.

Open Download Folder
import 'package:downloadsfolder/downloadsfolder.dart';

void main() async {
  final bool success = await openDownloadFolder();
  if (success) {
    print('Download folder opened successfully.');
  } else {
    print('Failed to open download folder.');
  }
}

카테고리

의존성

의존성 목록 5 개

소스 저장소

이 패키지를 사용하는 프로젝트