directory_picker 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 77

Directory Picker #

pub

A flutter package to pick directories and handles requesting required permissions as well. This package only supports android.

Picker Screenshot

Installation #

Add below line to your pubspec.yaml and run flutter packages get

directory_picker: ^1.0.0

NOTE: As of version 1.0.0 this plugin switched to the AndroidX version of the Android Support Libraries. This means you need to make sure your Android project is also upgraded to support AndroidX. Detailed instructions can be found here. Use version 0.2.2 if you do not want to use AndroidX(not recommended) for your project.

The TL;DR version is:

  1. Add the following to your "gradle.properties" file:
android.useAndroidX=true
android.enableJetifier=true
  1. Make sure you set the compileSdkVersion in your "android/app/build.gradle" file to 28:
android {
 compileSdkVersion 28

 ...
}
  1. Make sure you replace all the android. dependencies to their AndroidX counterparts (a full list can be found here: https://developer.android.com/jetpack/androidx/migrate).

Permissions #

Add below line to your android/app/src/main/AndroidManifest.xml

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

If you want to allow creating new folders directly from picker then add the below permission also

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

Usage #

import 'package:directory_picker/directory_picker.dart';
import 'package:path_provider/path_provider.dart';

// In any callback call the below method 
Directory newaDirectory = await DirectoryPicker.pick(
  context: context,
  rootDirectory: directory
);

if (newDirectory != null) {
  // Do something with the picked directory
} else {
  // User cancelled without picking any directory
}

See example app for more detailed usage.

TODO #

  • [ ] Make rootDirectory optional.
  • [ ] Better levels of customisation for picker dialog.

[1.0.0]

  • Migrated to AndroidX.
  • Changed permission handling plugin from simple_permissions to permissions_handler.

[0.2.2]

  • Fixes a bug with permission handling.

[0.2.1]

  • Added a missing dependency to pubspec.yaml.

[0.2.0]

  • Now new folders can be created directly from directory picker. Enable it by passing allowFolderCreation = true to the picker.

[0.1.0]

  • Fixes typo in README
  • Code formatted and version bump to release.

[0.0.1]

  • Adds initial version of directory_picker

example/README.md

Directory Picker Example #

This example shows how to use directory_picker plugin.

Use this package as a library

1. Depend on it

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


dependencies:
  directory_picker: ^1.0.0

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:directory_picker/directory_picker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
54
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
77
Learn more about scoring.

We analyzed this package on Oct 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/directory_picker.dart.

Run flutter format to format lib/directory_picker.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
path ^1.6.2 1.6.4
permission_handler ^3.2.2 3.3.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test