dartpub.dev DartNative · beta
plugins / native_data_protection
na

native_data_protection

v0.1.1 MIT

iOS file protection and backup exclusion for DartNative.

Apply native iOS file-protection policies and backup exclusion to existing files and directories in your app data container. Supports recursive updates, hidden files, and verification of applied settings.

by tayormi/native_data_protection · DartNative ≥ 3.0 · updated 4 days ago
Install
Free
pubspec.yaml
dependencies:
  native_data_protection:
    hosted: https://dartpub.dev
    version: ^0.1.1
Weekly installs
1
Active apps
3
Rating
0.0 · 0
Open issues
0

native_data_protection

Set iOS file protection and exclude files from backups in DartNative.

Install

Add to your DartNative app's pubspec.yaml:

dependencies:
  native_data_protection:
    hosted: https://dartpub.dev
    version: ^0.1.1

Run dn pub get, then rebuild the app to link the native plugin. Use the generated plugin registrant provided by your DartNative app template.

Use

import 'package:native_data_protection/native_data_protection.dart';

// The directory must already exist inside your app's data container.
void protectFiles(String directoryPath) {
  final files = NativeDataProtection();
  files.protect(
    directoryPath,
    protection: NativeFileProtection.complete,
    excludeFromBackup: true,
    recursive: true,
  );
  final status = files.status(directoryPath);
  print(status.protection);
}

Notes

  • iOS only, with a native deployment target of iOS 15+. Your DartNative SDK may require a newer OS.
  • Paths must already exist inside the app's data container. Symlinks and outside paths are rejected.
  • Protection defaults to complete and backup exclusion defaults to true. Applied settings are checked; failures throw DataProtectionException.
  • Recursive changes include hidden files and are not atomic. Coordinate file writes, and test protection on a physical device: the simulator does not expose every protection attribute.

See API notes for protection policies and filesystem behavior.

MIT license.