mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-10 19:27:01 +01:00
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
16 lines
618 B
Dart
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);
|
|
}
|