fromItem static method
Decodes one item from the native ux/drop/events drop payload. Returns
null when the item carries no usable path (so a malformed item is
skipped rather than yielding a phantom file). Exposed for testing the wire
decode; the channel itself is exercised end-to-end on device.
Implementation
@visibleForTesting
static XDropFile? fromItem(Map<Object?, Object?> item) {
final path = item['path'];
if (path is! String || path.isEmpty) return null;
final name = item['name'];
return XDropFile(
path: path,
name: name is String && name.isNotEmpty ? name : path.split('/').last,
mimeType: item['mimeType'] as String?,
bookmark: item['bookmark'] as Uint8List?,
isTemporaryCopy: item['isTemporaryCopy'] as bool? ?? false,
isDirectory: item['isDirectory'] as bool? ?? false,
);
}