todo-app/lib/ui/image_input_files.dart
Krzysztof kuhy Rudnicki 0798f7b1d0 Attach images to notes, stored on dufs and kept offline
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-25 14:11:15 +02:00

16 lines
618 B
Dart

/// Which of a paste's or drop's files are images: split out of the web-only
/// listener so the decision is unit-testable on the VM.
library;
/// Indices of the files whose MIME type is an image, and how many were not.
///
/// Order is preserved: files dropped together are attached in the order the
/// browser lists them.
({List<int> images, int rejected}) partitionImageFiles(List<String> mimeTypes) {
final images = <int>[
for (var i = 0; i < mimeTypes.length; i++)
if (mimeTypes[i].toLowerCase().startsWith('image/')) i,
];
return (images: images, rejected: mimeTypes.length - images.length);
}