mvvm_lite 0.2.0
mvvm_lite: ^0.2.0 copied to clipboard
A tiny, zero-dependency MVVM toolkit for Flutter — ViewModel base class with lifecycle tracking, scoped provider, granular Selector, and Consumer.
0.2.0 #
- Behavior change:
ViewModelProvidernow creates its view model ininitStateinstead of lazily on first build. This fixes a latent bug where a throwingcreate(or a throw during the first build) re-rancreatea second time duringdispose, masking the original error. The view model is now created exactly once. - Behavior change:
context.readVm<VM>(),Consumer, andSelectornow throw a descriptiveFlutterErrorwhen no matchingViewModelProvideris in scope — in both debug and release builds. Previously this was a debug-onlyassert, so release builds surfaced an opaque null-check error instead. - Documented that
Consumer/Selectorresolve the view model by state type (nearest provider wins), whereasreadVmresolves by view-model type — use a dedicated state class per provider. - Tooling: bumped the
lintsdev-dependency to^6.1.0and enabled thedirectives_orderingandalways_declare_return_typeslints. No change to the supported SDK floor (Dart >=3.0.0,Flutter >=3.10.0).
0.1.0 #
Initial release.
ViewModel<S>—ChangeNotifier-based base class with immutable state,mountedlifecycle flag, and abindStreamhelper for "subscribe once, listen forever" patterns.ViewModelProvider<VM, S>— widget that creates, scopes, and disposes a view model for a subtree. Supports eitherchildorbuilder.Consumer<S>— rebuilds on every state change.Selector<S, T>— rebuilds only when a derived projection changes; supports a customshouldRebuildfor value-equality-less types.BuildContext.readVm<VM>()— retrieves the view model without subscribing.