mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-10 19:07:17 +01:00
Save-as on mobile (SAF), save dialog on desktop, download on web; versioned envelope helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWXTUM9dpnCS2wtFkx4
38 lines
930 B
Dart
38 lines
930 B
Dart
import 'package:data_transfer_flutter/data_transfer_flutter.dart';
|
|
|
|
/// Records what the facade asked the platform to do.
|
|
class FakePlatform implements DataTransferPlatform {
|
|
/// What every save/share returns; false stands for a cancelled dialog.
|
|
bool accept = true;
|
|
|
|
/// What [pickText] returns; null stands for a cancelled picker.
|
|
String? picked;
|
|
|
|
/// `(fileName, text)` of every [saveText] call.
|
|
final saves = <(String, String)>[];
|
|
|
|
/// `(fileName, text)` of every [shareText] call.
|
|
final shares = <(String, String)>[];
|
|
|
|
@override
|
|
Future<bool> saveText({
|
|
required String fileName,
|
|
required String text,
|
|
}) async {
|
|
saves.add((fileName, text));
|
|
return accept;
|
|
}
|
|
|
|
@override
|
|
Future<bool> shareText({
|
|
required String fileName,
|
|
required String text,
|
|
}) async {
|
|
shares.add((fileName, text));
|
|
return accept;
|
|
}
|
|
|
|
@override
|
|
Future<String?> pickText() async => picked;
|
|
}
|