all_box 0.2.0
all_box: ^0.2.0 copied to clipboard
Synchronous, lightweight key-value storage for Flutter with crash-safe writes (write-ahead + atomic rename) and a pure-Flutter reactive layer.
0.2.0 #
AllBox.init()gains aninitialDataparameter, seeding default values on a genuine first run only (checked via the presence of<container>.db/<container>.bakon disk, not via in-memory state, so a container emptied by a previouserase()is correctly never reseeded). The seed is persisted immediately, bypassing the debounce window.write()/writeAndFlush()no longer throwArgumentErrorfor a non-JSON-encodable value. In debug builds only, they now log a louddebugPrintwarning (wrapped in ANSI red) instead, matchingGetStorage's permissive behavior — the write still goes through in memory either way.
0.1.0 #
Initial release.
- Synchronous in-memory reads (
read,readOrDefault,hasData,getKeys,getValues). - Optimistic, debounced writes (
write) and forced-flush writes (writeAndFlush);flushNow()to bypass the debounce window on demand (e.g.AppLifecycleState.paused). - One file per container, JSON-encoded via
dart:convert. - Write-ahead crash-safety: writes land on
<container>.tmpfirst, then an atomic rename replaces<container>.db; the previous good file is kept as<container>.bak. - Two-stage read error handling (UTF-8 decoding vs. JSON parsing), each
falling back to
<container>.bak, then to an empty container —init()never throws on a corrupted file. - Serialized flush queue: concurrent
writeAsStringcalls on the same file are never allowed to race. pathis a required parameter ofAllBox.init()— no internalpath_providerdependency, no plugin-pathMissingPluginExceptionrisk.listenKey/removeListenKey,listenAll(returns a dispose callback),erase()notifying every previously-existing key's listeners.AllBoxListenable<T>(ChangeNotifier+ValueListenable<T?>) andAllBoxBuilder<T>widget — pure-Flutter reactive layer.- Optional
.val()extension onString, DI-free. AllBox.initWithMemoryBackendForTesting()— pure in-memory backend for apps/packages that consumeall_boxto unit/widget-test their own code, with no real disk I/O and no realTimerscheduled onwrite().write()/writeAndFlush()validated that the value was JSON-encodable synchronously and threwArgumentErrorimmediately if not (superseded in 0.2.0 by a debug-only warning — see above).- No Web support in this release (documented limitation). Not isolate-safe (documented limitation).