auto_save_controller 1.0.0
auto_save_controller: ^1.0.0 copied to clipboard
A Flutter TextEditingController that automatically saves and loads local text drafts with built-in debounce, TTL expiry, and AppLifecycle awareness.
Changelog #
All notable changes to auto_save_controller will be documented in this file.
1.0.0 #
Initial release.
Features #
AutoSaveTextEditingController— a drop-inTextEditingControllerreplacement that automatically persists and restores text drafts.AutoSaveControllertypedef — a concise alias forAutoSaveTextEditingControllerto reduce boilerplate in consuming code.- Debounce — configurable
debounceDuration(default 500 ms) prevents excessive write operations during active typing. - TTL (Time-To-Live) — optional
maxDraftAgeautomatically expires and deletes stale drafts on load. - AppLifecycle awareness — pending debounce timers are flushed immediately when the app becomes inactive, paused, or detached, preventing draft loss.
- Storage-agnostic design — the
AutoSaveStorageabstract interface decouples the controller from any specific storage backend; bring your own implementation. - Global configuration —
AutoSave.init(storage:)registers a single-instance fallback storage used by all controllers that do not provide their ownstorageargument. - Per-controller injection — pass a
storageargument directly to the constructor to override the global instance on a per-controller basis. - Length guard —
maxDraftLength(default 10 000 chars) silently skips saves for oversized drafts without deleting previously saved content. - Empty-text guard — saving an empty text field deletes the stored draft, keeping storage clean.
- Priority control —
prioritizeDraftOverInitialgoverns whether a restored draft overwrites an explicitly provided initial text value. clearDraft()— programmatically deletes the persisted draft and resets the text field in one call.- Zero third-party dependencies — only the Flutter SDK is required.