dartpub.dev DartNative · beta
plugins / dartnative_path_provider
dp

dartnative_path_provider

v1.0.0 dartpub Free

Native app directory paths

The native app-directory paths for DartNative — synchronous, FFI-backed documents, support, cache, and temp directories with no `MethodChannel` and no `await`. A drop-in for `path_provider`.

by DartNative/dartnative_path_provider · DartNative ≥ 3.0 · updated 3 weeks ago
Install
Free
pubspec.yaml
dependencies:
  dartnative_path_provider: ^1.0.0
Weekly installs
40
Active apps
12
Rating
0.0 · 0
Open issues
0

dartnative_path_provider

Synchronous, FFI-backed app directories for DartNative apps — documents, support, cache, and temp paths on iOS and Android, with no MethodChannel and no await.

Why you'll like it

  • Synchronous — every call returns a String path directly, not a Future<Directory>. No await, no plugin-channel round-trip.
  • Both platforms — iOS and Android from one import; the right native source is resolved at runtime.
  • Drop-in — same names as path_provider, so porting is mostly deleting await.

Highlights

  • getApplicationDocumentsDirectory() — user documents that should be backed up.
  • getApplicationSupportDirectory() — app-support files the user shouldn't touch.
  • getApplicationCacheDirectory() — cache files, longer-lived than temp.
  • getTemporaryDirectory() — transient cache the OS may purge.

Install

dependencies:
  dartnative_path_provider: ^1.0.0   # from dartpub.dev
dn pub get
void main() {
  DartNativePluginRegistrant.registerAll();
  runApp(const MyApp());
}

Quick look

import 'package:dartnative_path_provider/dartnative_path_provider.dart';

final docs    = getApplicationDocumentsDirectory();  // backed-up user documents
final support = getApplicationSupportDirectory();     // app-support files
final cache   = getApplicationCacheDirectory();       // longer-lived cache
final tmp     = getTemporaryDirectory();              // purgeable cache

final db = File('$docs/app.db');

No await — paths are resolved synchronously over FFI. The plugin ships its own native code on both platforms: a Swift bridge compiled into the app on iOS (DynamicLibrary.process()), and its own libdartnative_path_provider.so on Android.

Platform setup

No config files or manifest entries on either platform. The one requirement: Android minSdk 26 — set it in android/app/build.gradle.kts:

android { defaultConfig { minSdk = 26 } }

Example

The example/ app resolves and shows the directories — borrow from it freely.

Run it:

cd example
dn pub get
dn run -d <device-id>

The example is an official demo — free to run, no license setup. Always use dn for run/build/pub commands.

Credits & license

API-compatible with path_provider (BSD-3-Clause), reworked to synchronous FFI.

Distributed via dartpub.dev — file issues on the plugin's page.