mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-10 22:27:13 +01:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWXTUM9dpnCS2wtFkx4
44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
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)>[];
|
|
|
|
/// The mime type of every [saveText] call, in order.
|
|
final saveMimes = <String>[];
|
|
|
|
/// `(fileName, text)` of every [shareText] call.
|
|
final shares = <(String, String)>[];
|
|
|
|
@override
|
|
Future<bool> saveText({
|
|
required String fileName,
|
|
required String text,
|
|
String mimeType = 'application/json',
|
|
}) async {
|
|
saves.add((fileName, text));
|
|
saveMimes.add(mimeType);
|
|
return accept;
|
|
}
|
|
|
|
@override
|
|
Future<bool> shareText({
|
|
required String fileName,
|
|
required String text,
|
|
String mimeType = 'application/json',
|
|
}) async {
|
|
shares.add((fileName, text));
|
|
return accept;
|
|
}
|
|
|
|
@override
|
|
Future<String?> pickText() async => picked;
|
|
}
|