Catch-all commit for outstanding pre-existing local changes. Mixes several themes that would normally be split: - Rename: UxPlugin → XPlugin across iOS, macOS, Android registrants. - New top-level packages under lib/src/: anim/ (animated values, panes, sheets, dock, measured), core/ (Emitter, ReactiveBuilder scaffolding, presenter/widget/value/dispose primitives), navi/ (Screen/ScreenStack/Router/hero/transitions), reactive/. - Edits across existing plugins (clipboard, crash, file, gallery, keyboard, scanner, sensor, url) to align with the new core. - Test updates and CHANGELOG/README touches accompanying the above.
29 lines
1017 B
Dart
29 lines
1017 B
Dart
import 'package:flutter/services.dart';
|
|
|
|
/// OS clipboard access for shapes Flutter's [Clipboard] doesn't cover.
|
|
/// Right now this is image bytes — the system text path is already
|
|
/// handled by the SDK's `Clipboard.getData(Clipboard.kTextPlain)`.
|
|
class XClipboard {
|
|
XClipboard._();
|
|
|
|
static const _channel = MethodChannel('ux/clipboard');
|
|
|
|
/// Returns the image currently on the system clipboard as raw bytes
|
|
/// (PNG on iOS / macOS / Android), or `null` if no image is available.
|
|
///
|
|
/// On macOS the call also handles TIFF clipboards by transcoding to
|
|
/// PNG; Android resolves `content://` URIs through ContentResolver and
|
|
/// returns the underlying image bytes verbatim. Never throws — channel
|
|
/// failures resolve to `null`.
|
|
static Future<Uint8List?> readImage() async {
|
|
try {
|
|
final bytes = await _channel.invokeMethod<Uint8List>('readImage');
|
|
return bytes;
|
|
} on PlatformException {
|
|
return null;
|
|
} on MissingPluginException {
|
|
return null;
|
|
}
|
|
}
|
|
}
|