flutter_smart_upload 0.1.0
flutter_smart_upload: ^0.1.0 copied to clipboard
Backend-agnostic, memory-efficient file uploads for Flutter — chunked, resumable, retrying, with pause/resume/cancel, a concurrency-limited queue and pluggable adapters.
Changelog #
0.1.0 #
First release.
Core #
SmartUploader— queue, retry, progress, persistence and lifecycle in one facade.UploadAdapter— the four-method seam between this package and any backend. No HTTP client, no vendor SDK, no assumptions about your protocol.UploadTask— per-upload handle withpause(),resume(),cancel(),done, and status/progress streams.
Reliability #
- Chunked uploads with a configurable size (default 2 MB), read through a
single
RandomAccessFileso peak memory is one chunk regardless of file size. - Per-chunk retry with exponential backoff and jitter; permanent errors (auth, invalid file, malformed request) are never retried.
- Resumable uploads: state is persisted after every acknowledged chunk and transfers continue at the first chunk the server does not hold.
- Pause, resume and cancel, individually or across the whole queue.
- Concurrency-limited, priority-aware queue.
- Connectivity-aware: uploads park while offline instead of retrying into a dead connection.
Optimisation #
ImageCompressor— resize, re-encode and strip EXIF in a background isolate, with a pixel-count guard for low-memory devices.- Opt-in checksums: MD5, SHA-256, base64 MD5 and a free stat-based fingerprint. Resume verifies the file has not changed.
Persistence #
MemoryUploadStorage(default) andFileUploadStorage(atomic JSON files, survives app restarts), behind a replaceableUploadStorageinterface.
Developer experience #
- Sealed
UploadEventhierarchy for exhaustiveswitch. - Typed
SmartUploadExceptionwith stable error codes and retryability. InMemoryUploadAdapterfor tests and demos.- Example app covering single and multiple uploads, progress with speed and ETA, pause/resume/cancel/retry, simulated flaky server and offline mode.
- 133 tests covering chunking, ordering, retries, resume, persistence, cancellation, concurrency, compression, checksums and memory behaviour, plus widget tests for the example.