flutter_file_path_provider 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

flutter_file_path_provider #

flutter_file_path_provider 是一款用于读取设备上存储目录的 Flutter 插件,同时支持 AndroidiOS 两个平台。

该插件已经发布,使用信息请移步 flutter_file_path_provider

Getting Started #

第一步:在 pubspec.yaml 文件中声明需要使用的插件:

   flutter_file_path_provider: ^0.0.3


$ flutter packages get


import 'package:flutter_file_path_provider/flutter_file_path_provider.dart';


    FlutterFilePathProvider.instance.getExternalStorageDirectory().then((result) {
    // 处理结果

API 说明 #

  • getExternalStorageDirectory() 返回设备的 SD 卡根目录,该方法只在 Android 平台有效,iOS 平台调用将会返回对应的错误信息。其对应 Android 平台上 Environment.getExternalStorageDirectory().getAbsolutePath() 的值
  • getHomeDirectory() 返回设备的沙盒根目录,该方法只在 iOS 平台有效,Android 平台调用将会返回对应的错误信息。其对应 iOS 平台上 NSHomeDirectory() 的值
  • getExternalStorageTemporaryDirectory()getInternalStorageTemporaryDirectory() 返回设备的临时目录。对于 Android 平台来说,两个方法分别对应 String.format(getContext().getExternalCacheDir().getParent() + "%s", "/temp/")String.format(getContext().getCacheDir().getParent() + "%s", "/temp/") 的值,而对于 iOS 设备来说,则对应 NSTemporaryDirectory() 的值
  • getExternalStorageCacheDirectory()getInternalStorageCacheDirectory() 返回设备的缓存目录。对于 Android 平台来说,两个方法分别对应 getContext().getExternalCacheDir().getAbsolutePath()getContext().getCacheDir().getAbsolutePath() 的值,而对于 iOS 平台,则对应 NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject 的值
  • getExternalStorageFileDirectory()getInternalStorageFileDirectory() 返回设备的存储目录。对于 Android 平台来说,两个方法分别对应 String.format(getContext().getExternalCacheDir().getParentFile().getAbsolutePath() + "%s", "/files/")getContext().getFilesDir().getAbsolutePath() 的值,而对于 iOS 设备来说,则对应 NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES).firstObject 的值

FlutterFilePathResult #

FlutterFilePathResult 是结果的载体,其内部定义了用于表示错误码的 code 对象、表示错误信息的 message 对象和最终的结果 directory 对象。当且仅当 code 值为 0 时,directory 的值才有意义。

code 错误码:

  • 0:返回成功
  • 10:读到的结果为空
  • 11:读取过程中出现异常
  • 12:没有对应的方法
  • 13: 不支持该方法

0.0.1 #

  • TODO: Describe initial release.

0.0.2 #

  • 完善接入文档
  • 修改部分 Android 平台类名

0.0.3 #

  • 移除无用注释以及部分调试信息


flutter_file_path_provider_example #

Demonstrates how to use the flutter_file_path_provider plugin

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_file_path_provider: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_file_path_provider/flutter_file_path_provider.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health issues and suggestions

Document public APIs. (-1 points)

20 out of 20 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/flutter_file_path_provider.dart.

Run flutter format to format lib/flutter_file_path_provider.dart.

Maintenance issues and suggestions

The description contains too many non-ASCII characters. (-20 points)

The site uses English as its primary language. The value of the description field in your package's pubspec.yaml field should primarily contain characters used in English.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies