utils/data_transfer_flutter
Krzysztof kuhy Rudnicki d4fca83c9f data_transfer_flutter 0.2.1: file_picker 13.3.2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-08 18:01:34 +01:00
..
lib data_transfer_flutter 0.2.0: exportTextFile + mime types 2026-11-01 19:46:05 +01:00
scripts data_transfer_flutter 0.1.0: shared JSON export/import 2026-11-01 19:46:05 +01:00
test data_transfer_flutter 0.2.0: exportTextFile + mime types 2026-11-01 19:46:05 +01:00
.gitignore data_transfer_flutter 0.1.0: shared JSON export/import 2026-11-01 19:46:05 +01:00
.pre-commit-config.yaml data_transfer_flutter 0.1.0: shared JSON export/import 2026-11-01 19:46:05 +01:00
analysis_options.yaml data_transfer_flutter 0.1.0: shared JSON export/import 2026-11-01 19:46:05 +01:00
pubspec.yaml data_transfer_flutter 0.2.1: file_picker 13.3.2 2026-11-08 18:01:34 +01:00
README.md data_transfer_flutter 0.2.1: file_picker 13.3.2 2026-11-08 18:01:34 +01:00

data_transfer_flutter

Shared "export to a JSON file / import from a JSON file" plumbing for kuhy's Flutter apps. Apps keep their own export CONTENT; this owns the file plumbing and the envelope.

Install

dependencies:
  data_transfer_flutter:
    git:
      url: https://github.com/kuhyx/utils
      ref: data_transfer_flutter-v0.2.1
      path: data_transfer_flutter

Use

final saved = await exportJson(fileName: 'x.json', json: envelope);
final map = await pickJson(); // null when cancelled
  • exportJson / exportJsonText save to device storage: Android and iOS use the system "Save as" document picker (file_picker saveFile, i.e. ACTION_CREATE_DOCUMENT), desktop a save dialog (file_selector), web a browser download. Returns false when cancelled.
  • exportTextFile does the same for any text (text/csv, text/calendar).
  • shareJson is an optional second action (share sheet). It is never the only way out: a stock phone's share sheet has no local save target.
  • pickJson / pickJsonText use the system open-document picker.
  • buildEnvelope / validateEnvelope / parseEnvelope write and check {format, version, exported_at, ...}; mismatches throw a typed EnvelopeException (always a FormatException).

Tests fake DataTransfer.platform (a DataTransferPlatform); restore it in tearDown.