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

套件詳情v0.0.2+1

cr_file_saver

允許在 Android 和 IOS 設備上儲存檔案,並在需要時請求權限。

AndroidiOS
近 30 天下載
8
喜歡數
34
Pub 分數
150

安裝套件

flutter pub add cr_file_saver

套件介紹

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

cr_file_saver 是一個 Flutter 套件,可將檔案儲存至 Android 與 iOS 裝置,並在需要時自動處理權限請求。它透過抽象平台特定細節來簡化檔案操作,讓使用者能輕鬆將圖片、文件或資料匯出直接儲存在裝置上。此套件與 Flutter 應用程式無縫整合,支援兩個平台並提供一致的 API。非常適合需要離線檔案儲存或匯出功能的應用程式。

適用情境

  • 儲存匯出的文件
  • 儲存應用程式產生的影像
  • 匯出資料到本機儲存
  • 處理檔案下載
  • 管理使用者產生的內容

主要特色

  • 自動權限處理
  • 跨平台支援(Android 與 iOS)
  • 用於檔案儲存的簡單 API
  • 支援多種檔案類型
  • 內建錯誤管理

適合對象

  • 需要檔案匯出的應用
  • 媒體密集型應用
  • 離線資料儲存
  • 文件管理工具
  • 用戶內容儲存

使用建議

  • Android 運行時權限需求
  • 僅限檔案儲存(不支援讀取)
  • 平台特定的行為可能有所差異
  • 無內建檔案瀏覽
  • 依賴原生作業系統檔案系統存取

原始 README

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

cr_file_saver

Header image

Cleveroad introduces file saver for Flutter

Features:
  • Request WriteExternalStoragePermission for Android if needed.
  • Save file to downloads directory on Android or Document folder on IOS.
  • Save file through standard file saving dialog.
Future features:
  • Saving file to a specific directory.

Setup

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  cr_file_saver: ^0.0.2
Android:

If you are using android 9 and below add this permission to project manifest:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
iOS:

Add permissions in ios folder, go to ios/Runner/info.plist and add next keys:

<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>

In your dart file add the following import:

import 'package:cr_file_saver/cr_file_saver.dart';

Usage

CRFileSaver has several static methods to work with:

  • requestWriteExternalStoragePermission to check for permission and ask it if needed.
  • saveFile simply saving file with provided file path and desired file name.
  • saveFileWithDialog save file through standard file saving dialog. Note that this method will throw NoResolvedActivityException if Android device has 30 api or higher

所屬分類

依賴

依賴清單 1 項

  • plugin_platform_interface^2.1.2

原始碼儲存庫

使用此套件的專案