flutterx_preferences 2.0.0
flutterx_preferences: ^2.0.0 copied to clipboard
Persistent and session key-value storage exposed as a synchronous Map<String, String>, with typed accessors for bool, int, double, JSON and lists.
2.0.0 #
Major release: rewritten on Dart 3.11 / Flutter 3.41 with package:web, atomic file writes and a single instance per
storage. The synchronous Storage = Map<String, String> contract and the on-disk files are unchanged: existing data on
mobile and desktop is read without migration.
- Breaking: requires Dart
^3.11.0and Flutter>=3.41.0. - Breaking:
localStorageandsessionStorageare getters on every platform (they were reassignable variables on IO). - Breaking:
Preferences.set<T>,get<T>andopt<T>removed: usesetString/setJson/setListand the typed accessors. - Breaking:
setList<T>(key, Iterable<T>?, {required encode}):encodeis required and items are no longer JSON-encoded twice; the stored format equals the one produced before with an explicitencode. - Breaking:
optBool/getBoolaccept only'true'and'false'; any other value reads asnull/fallback (it wasfalse). - Breaking:
optJson/getJson/optList/getListreturnnull/fallback when the stored text is malformed (they threw); exceptions thrown byfromJson/decodealways propagate. - Breaking: storage names must match
^[A-Za-z0-9_-]+$, otherwiseArgumentError. - Breaking (web): named storages are stored under the key
flutterx_preferences:<name>(was<name>) andPreferences.local()without a name useswindow.localStoragedirectly (was a blob under_local_). Data saved on the web withloadLocalStorage/Preferences.localis not read anymore;localStoragehides the reserved keys. - New
setJson(key, Map<String, Object?>?). localStorageandPreferences.local()are the same instance, as areloadLocalStorage(name)andPreferences.local(name): writes are no longer lost between copies.- IO writes are atomic (temporary file + rename); a file that cannot be read or decoded loads as an empty storage and
is reported with
FlutterError.reportErrorinstead of crashing the app; non-string values are read as their JSON text. - Removed the
platformdependency anddart:html. - Integration skills for Claude Code in
.claude-plugin/andskills/.
Migration from 1.x #
- Raise the app to Dart 3.11 / Flutter 3.41 and depend on
flutterx_preferences: ^2.0.0. - Replace assignments to
localStorage/sessionStoragewith writes into the map (localStorage.addAll(...)). - Replace
prefs.set<T>(key, value)withsetString,setInt,setJson(key, value.toJson())orsetList(key, values, encode: ...); replaceget<T>/opt<T>with the typed accessor plus your own conversion. - Add
encode:to everysetListcall (encode: (s) => sfor strings; for other types the encoder you pass togetList'sdecodecounterpart). - If the app relied on
optBoolreturningfalsefor unknown values, usegetBool(key, fallback: false). - Use only letters, digits,
_and-in storage names. - Web only: to keep data written by 1.x with
Preferences.local('x'), copywindow.localStorage['x']intoloadLocalStorage('x')once at startup.
1.2.5 #
- Remove LiveData dependency
1.2.4 #
- Refactoring, add local storage map support
1.2.3 #
- Fix web error
1.2.2 #
- Refactoring
1.2.1 #
- Add json methods
1.2.0 #
- Improvements
1.1.1-dev #
- Improvements
1.1.0 #
- Initial stable release
1.0.5-dev #
- Platform management improvements.
1.0.4-dev #
- Add web support.
1.0.3-dev #
- Fix dispatcher for LivePreferences.
1.0.2-dev #
- Make everything synchronous.
1.0.1-dev #
- Fix.
1.0.0-dev #
- Initial release.