搜尋套件、儲存庫與 APP 分類

套件詳情v3.3.6

flutter_file_dialog

用於在 Android 和 iOS 上選擇和儲存檔案的對話方塊。

AndroidiOS
近 30 天下載
9.7萬
喜歡數
110
Pub 分數
160

安裝套件

flutter pub add flutter_file_dialog

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,為 Android 與 iOS 提供原生檔案選擇器與儲存對話方塊。它讓使用者能夠從裝置中選擇檔案,或透過系統原生介面儲存檔案,確保跨平台的一致體驗。此套件可順暢整合至 Flutter 應用程式中,提供簡單的 API 來觸發檔案作業,無需自訂 UI。支援常見檔案類型,並尊重平台特定的檔案存取權限與限制。

適用情境

  • 從設備存儲中選擇檔案
  • 將檔案儲存到裝置
  • 在跨平台應用中整合原生檔案對話框
  • 處理媒體或文件應用中的檔案輸入
  • 啟用使用者驅動的檔案管理
  • 支援檔案匯入/匯出工作流程

主要特色

  • Android 與 iOS 的原生對話框整合
  • 用於檔案選擇與儲存的簡單 API
  • 跨平台相容性
  • 尊重平台特定的檔案存取規則
  • 所需的設定最少
  • 支援常見檔案類型

適合對象

  • 需要檔案選擇或儲存的應用
  • 同時針對 Android 和 iOS 的開發者
  • 需要原生檔案 UI 的專案
  • 媒體或文件管理應用
  • 需要使用者驅動檔案處理的應用程式

使用建議

  • 需要適當的平台權限
  • 僅限檔案選擇/儲存操作
  • 不支援網頁或桌面平台
  • 依賴原生作業系統檔案系統存取
  • 可能需要為特定檔案類型進行額外設定

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

flutter_file_dialog

Dialogs for picking and saving files and for picking directories in Android and in iOS.

Features

  • Supports Android (API level 24 or later) and iOS (13.0 or later).
  • Modern plugin implementation based on Kotlin (Android) and Swift (iOS).
  • Pick image files and other documents.
  • Save a file to a selected location.
  • Pick a directory and save files to the picked directory without further dialogs.
  • iOS dialog types: document and image.
  • iOS source types: camera, photo library, saved photos album.
  • Allow user to edit the picked image in iOS.
  • Set file extension filter and mime types filter when picking a document.
  • Possibility to limit picking a file from the local device only (Android).

Examples

Pick an image file
  final params = OpenFileDialogParams(
    dialogType: OpenFileDialogType.image,
    sourceType: SourceType.photoLibrary,
  );
  final filePath = await FlutterFileDialog.pickFile(params: params);
  print(filePath);
Pick a document
  final params = OpenFileDialogParams(
    dialogType: OpenFileDialogType,
    sourceType: SourceType.photoLibrary,
  );
  final filePath = await FlutterFileDialog.pickFile(params: params);
  print(filePath);
Save a file
final params = SaveFileDialogParams(sourceFilePath: "path_of_file_to_save");
final filePath = await FlutterFileDialog.saveFile(params: params);
print(filePath);
Pick a directory and save a file to the picked directory
if (!await FlutterFileDialog.isPickDirectorySupported()) {
  print("Picking directory not supported");
  return;
}

final pickedDirectory = await FlutterFileDialog.pickDirectory();

if (pickedDirectory != null) {
  final filePath = await FlutterFileDialog.saveFileToDirectory(
    directory: pickedDirectory!,
    data: file.readAsBytesSync(),
    mimeType: "image/jpeg",
    fileName: "fileName.jpeg",
    replace: true,
  );
}
Optimize picked image file using flutter_image_utilities

Use the plugin flutter_image_utilities to optimize a picked image file.

  final params = OpenFileDialogParams(
    dialogType: OpenFileDialogType.image,
    sourceType: SourceType.photoLibrary,
  );
  final filePath = await FlutterFileDialog.pickFile(params: params);
  print(filePath);

  if (filePath != null) {
    final pickedFile = File(filePath)

    // optimize the image file
    final optimizedFile = await FlutterImageUtilities.saveAsJpeg(
      sourceFile: pickedFile,
      quality: 60,
      maxWidth: 1920,
      maxHeight: 1024,
    );
  }

所屬分類

原始碼儲存庫

使用此套件的專案