搜索插件、代码仓与 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

源码仓库

使用此插件的项目