navhost_state 0.2.4
navhost_state: ^0.2.4 copied to clipboard
Reactive state management extensions for navhost — .obs values, Obs auto-tracking widget, ViewModelBuilder, and Listen.
0.2.4 #
- Broaden Dart SDK constraint from
^3.11.3to">=3.0.0"for compatibility with a wider range of Flutter versions. - Fix
Comparable<C>bound onminByOrNull,maxByOrNull, andsortedByDescending— loosened toComparable<dynamic>soint(which implementsComparable<num>) satisfies the bound at language version 3.0. - Fix
(_, _)wildcard parameter usage in tests — renamed to(_p, _q)for compatibility with Dart language versions below 3.7. - README: reorder sections — Usage now appears before Recommended pattern so readers see the API before the structural guidance.
0.2.3 #
- README: expand "Recommended pattern: state hoisting" section with a full explanation of the philosophy — unidirectional data flow, data-down/events-up diagram, and five concrete justifications (testability, explicit dependencies, framework-agnostic VMs, predictable lifetime, DI-friendly).
- README: add code examples to the collection extensions section so readers can see what each category of method does at a glance.
- README: clarify
ViewModellifecycle section — addinitState/disposesnippet showing how to callonInit/onDisposemanually when using state hoisting. - README: fix
rxRoutesexample to use the recommended private-field pattern (vm.countinstead ofvm.count.value). - README: fix incorrect integration disclaimer that claimed examples used public
Rxfields (they already followed the private-field pattern).
0.2.2 #
- Add explicit dependency on
package:collection(already a Flutter transitive dep). collection_extensions.dartnow delegates topackage:collectionfor methods it already provides (firstWhereOrNull,lastWhereOrNull,none,sortedBy,forEachIndexed,mapIndexed,singleWhereOrNull,whereNot,groupListsBy,slices) instead of reimplementing them. Our file now contains only genuinely missing methods plus ergonomic aliases (singleOrNull,filterNot,groupBy,chunked) that call the collection equivalents.
0.2.1 #
- Add
collection_extensions.dart— standalone Kotlin-inspired extension methods onIterable<E>,List<E>,Map<K,V>exported for use on plain Dart collections too.Iterable:firstWhereOrNull,lastWhereOrNull,singleOrNull,count,none,filterNot,sumOf,minByOrNull,maxByOrNull,groupBy,associateBy,associate,partition,distinctBy,flatMap,mapIndexed,forEachIndexed,onEach,chunked,zip,joinToString,drop,dropWhileList:sortedBy,sortedByDescending,indicesMap:mapValues,mapKeys,filterKeys,filterValues,filter,getOrDefault,getOrElse,none,all,count,minByOrNull,maxByOrNull,toList
RxList,RxMap,RxSetnow expose the full collection extension surface — all query methods are tracked, all delegation handled via an internal_trackhelper (one line per method, no duplicated logic).RxListadditions:singleOrNull,count,none,filterNot,mapIndexed,forEachIndexed,sumOf,minByOrNull,maxByOrNull,sortedBy,sortedByDescending,groupBy,associateBy,partition,distinctBy,flatMap,chunked,zip,joinToString,indices,removeWhere,[](tracked read)RxMapadditions:any,none,all,count,getOrDefault,getOrElse,mapValues,mapKeys,filterKeys,filterValues,filter,firstWhereOrNull,minByOrNull,maxByOrNull,toList,[](tracked read),containsValueRxSetadditions:every,none,count,firstWhereOrNull,lastWhereOrNull,singleOrNull,filterNot,map,sumOf,minByOrNull,maxByOrNull,groupBy,flatMap,joinToString,union,intersection,difference,toList,removeWhere
0.2.0 #
- Add
batch()— defers allRxnotifications produced inside the callback and flushes them together once it returns. Nested batches are safe; the flush happens only when the outermost batch completes. - Add
computed()— returns a read-onlyRx<T>whose value is derived from otherRxvalues and updates automatically when any dependency changes. Throws on direct assignment. - Add
Effect/effect()— runs a callback immediately and re-runs it whenever anyRxvalue read inside it changes. Returns anEffecthandle; calldispose()to stop tracking. - Add
RxList<E>— reactiveListwrapper that notifies on in-place mutations (add,remove,insert,clear,[]=).valuereturns an unmodifiable view. - Add
RxMap<K, V>— reactiveMapwrapper that notifies on in-place mutations ([]=,remove,addAll,clear).valuereturns an unmodifiable view. - Add
RxSet<E>— reactiveSetwrapper that notifies on in-place mutations (add,remove,addAll,clear).valuereturns an unmodifiable view. - Add
Rx.toStream()— exposes anRxas a single-subscriptionStreamof future changes (does not emit the current value on listen). Delivery is synchronous; cancelling removes the listener. - Add
fromStream<T>(stream, {required T initial})— creates anRx<T>that syncs its value from aStream. - Add
ViewModelbase class withonInit()andonDispose()lifecycle hooks.ViewModelScopecalls these automatically when the ViewModel enters and leaves the widget tree.
0.1.6 #
- Add
Rx.update(T Function(T previous) updater)— updates the value by applying a function to the current value, without registering a tracking dependency on the read. Useful for counters, list mutations, and any transformation that depends on the previous state.
0.1.5 #
- Add
ObsBuilder— likeObsbut with a namedbuilderparameter that receivesBuildContext. Use when you need the context inside a reactive builder (theme, navigation, dialogs).
0.1.4 #
- Broaden
navhostdependency constraint to>=0.1.4so navhost_state always resolves the latest compatible navhost version without requiring a manual bump.
0.1.3 #
- Update README install snippet to reference latest versions.
0.1.2 #
- Fix README example to use two-param route builder.
0.1.1 #
- ViewModels no longer need to extend
ChangeNotifier— plain classes work with.obs+Obs. ViewModelScopestores anyObject; onlyChangeNotifierinstances are auto-disposed.rxRoutes()updated for navhost 0.1.3 query parameter support.- Added integration examples (get_it, injectable, dio, shared_preferences, freezed, hive, firebase, web_socket_channel, flutter_secure_storage).
- Added migration guides from Provider, Riverpod, GetX, and Bloc/Cubit.
- Added tests for
Rx<List>,Rx<Map>, and plain class ViewModels.
0.1.0 #
- Initial release.
Rx<T>reactive value wrapper with.obsextension.Obsauto-tracking widget — rebuilds only when readRxvalues change.ViewModelScopefor scopingChangeNotifierViewModels to the widget lifecycle.rxRoutes()helper to wrap navhost routes withViewModelScopeautomatically.context.viewModel()extension for creating/retrieving scoped ViewModels.ViewModelBuilderconvenience widget (create + subscribe in one step).Listenwidget for subscribing to an existing scoped ViewModel.