stack_wallet/lib/utilities/clipboard_interface.dart
2022-08-26 16:11:35 +08:00

34 lines
743 B
Dart

import 'package:flutter/services.dart';
abstract class ClipboardInterface {
Future<void> setData(ClipboardData data);
Future<ClipboardData?> getData(String format);
}
class ClipboardWrapper implements ClipboardInterface {
const ClipboardWrapper();
@override
Future<ClipboardData?> getData(String format) {
return Clipboard.getData(format);
}
@override
Future<void> setData(ClipboardData data) async {
await Clipboard.setData(data);
}
}
class FakeClipboard implements ClipboardInterface {
String? _value;
@override
Future<ClipboardData> getData(String format) async {
return ClipboardData(text: _value);
}
@override
Future<void> setData(ClipboardData data) async {
_value = data.text;
}
}