2022-08-26 08:11:35 +00:00
|
|
|
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
|
2023-05-30 16:41:53 +00:00
|
|
|
Future<ClipboardData?> getData(String format) async {
|
|
|
|
return _value == null ? null : ClipboardData(text: _value!);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> setData(ClipboardData data) async {
|
|
|
|
_value = data.text;
|
|
|
|
}
|
|
|
|
}
|