mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-11 16:14:07 +01:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWXTUM9dpnCS2wtFkx4
33 lines
1.2 KiB
Dart
33 lines
1.2 KiB
Dart
/// What differs per host: where the bytes of an export go and come from.
|
|
///
|
|
/// The seam tests fake. Real implementations live in `platform_io.dart`
|
|
/// (Android, iOS, desktop) and `platform_web.dart`, chosen by
|
|
/// `platform_default.dart` so no `dart:io` import reaches a web build.
|
|
abstract interface class DataTransferPlatform {
|
|
/// Saves [text] as [fileName] where the user can find it again.
|
|
///
|
|
/// Android/iOS: the system "Save as" document picker (device storage).
|
|
/// Desktop: a save dialog. Web: a browser download. Returns false when the
|
|
/// user cancelled.
|
|
Future<bool> saveText({
|
|
required String fileName,
|
|
required String text,
|
|
String mimeType = 'application/json',
|
|
});
|
|
|
|
/// Offers [text] as [fileName] to the share sheet, where the host has one.
|
|
///
|
|
/// A second action only: a share sheet can route the data to cloud apps, so
|
|
/// it never replaces [saveText]. Hosts without a sheet fall back to
|
|
/// [saveText].
|
|
Future<bool> shareText({
|
|
required String fileName,
|
|
required String text,
|
|
String mimeType = 'application/json',
|
|
});
|
|
|
|
/// Opens the system open-document picker and returns the file's text, or
|
|
/// null when the user cancelled.
|
|
Future<String?> pickText();
|
|
}
|