read method
Reads clipboard contents. Note that on some platforms accessing clipboard may trigger a prompt for user to confirm clipboard access. This is the case on iOS and web.
For web the preferred way to get clipboard contents is through ClipboardEvents.registerPasteEventListener, which is triggered when user pastes something into the page and does not require any user confirmation.
Implementation
Future<ClipboardReader> read() async {
final reader = await raw.ClipboardReader.instance.newClipboardReader();
final readerItems = await reader.getItems();
final itemInfo = await raw.DataReaderItem.getItemInfo(readerItems);
final items = <ClipboardDataReader>[];
for (final item in itemInfo) {
items.add(ClipboardDataReader.forItemInfo(item));
}
return ClipboardReader(items);
}