flutter_absolute_path_provider

StandWithPalestine Pub Package

A tiny Flutter plugin that hands back the absolute path of common system directories on Android and iOS — Downloads, Documents, Pictures, DCIM, Music, and friends.

  • Android: real shared storage folders via Environment.getExternalStoragePublicDirectory.
  • iOS: a named subfolder under the app's sandboxed Documents/ directory, created on demand (since iOS apps cannot reach shared media folders).

Install

dependencies:
  flutter_absolute_path_provider: ^0.1.0
flutter pub get

Usage

import 'package:flutter_absolute_path_provider/flutter_absolute_path_provider.dart';

final downloads = await AbsolutePath.absoluteDirectory(dirType: DirectoryType.downloads);
final pictures  = await AbsolutePath.absoluteDirectory(dirType: DirectoryType.pictures);
final documents = await AbsolutePath.absoluteDirectory(dirType: DirectoryType.documents);

// Default is DirectoryType.downloads:
final dir = await AbsolutePath.absoluteDirectory();

Directory utilities

final dir = (await AbsolutePath.absoluteDirectory(dirType: DirectoryType.documents))!;

await dir.createIfNotExists();          // mkdir -p
final canWrite = await dir.isWritable;  // probe
await dir.ensureWritable();             // create + verify or throw

Error handling

try {
  final dir = await AbsolutePath.absoluteDirectory(dirType: DirectoryType.downloads);
  await dir?.ensureWritable();
} on DirectoryException catch (e) {
  debugPrint('Directory error: ${e.message} (code=${e.code})');
}

Supported DirectoryTypes

alarms · audioBooks · dcim · documents · downloads · movies · music
notifications · pictures · podcasts · recordings · ringtones · screenshots

Platform support

Platform Behavior
Android Maps to the matching public shared-storage folder.
iOS Named subfolder under app's Documents/, auto-created.
Web/desktop isPlatformSupported is false; calls return null.

Permissions

This plugin does not request runtime permissions. On Android, accessing or writing to shared storage may require READ_MEDIA_* / WRITE_EXTERNAL_STORAGE depending on the API level — pair it with a plugin like permission_handler.

Support

If this plugin helped, consider supporting the author:

Buy Me A Coffee