31 lines
1.1 KiB
Dart
31 lines
1.1 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
|
|
class PendingShare {
|
|
final List<String> filePaths;
|
|
final String? text;
|
|
final DateTime receivedAt;
|
|
|
|
/// Paths as delivered by the platform, before the listener moved them into
|
|
/// a per-share folder. Duplicate detection compares these, since the
|
|
/// relocated [filePaths] differ for every delivery.
|
|
final List<String> sourcePaths;
|
|
|
|
const PendingShare({
|
|
required this.filePaths,
|
|
required this.text,
|
|
required this.receivedAt,
|
|
List<String>? sourcePaths,
|
|
}) : sourcePaths = sourcePaths ?? filePaths;
|
|
|
|
bool get hasFiles => filePaths.isNotEmpty;
|
|
bool get hasText => text != null && text!.isNotEmpty;
|
|
bool get isEmpty => !hasFiles && !hasText;
|
|
|
|
/// True when [other] carries the same payload. The iOS Share Extension
|
|
/// fires two `open(url)` requests per share (see ShareViewController), so
|
|
/// the same share can arrive twice on the media stream — receivedAt is
|
|
/// deliberately ignored here so such duplicates compare equal.
|
|
bool contentEquals(PendingShare other) =>
|
|
text == other.text && listEquals(sourcePaths, other.sourcePaths);
|
|
}
|