Library to easily manage ViewModels aka controller classes in Flutter that bounded to the lifecycle of the widget.
Features
-
Three Viewmodel APIs in ViewModeMixin for State
- registerViewModel(create: ()=>ViewModel()) - instead of passing a viewmodel instance that is created from outside, we pass a function create to tell this API how to create a viewmodel.
- registerSharedViewModel(key: someStringConstant, createIfNull: ()=>ViewModel()) - this API shares viewmodel using the key which is a String constant. If the viewmodel associated with key is not already created anywhere in the application, a new viewmodel is created using the function createIfNull and stored
- getViewModel
-
For Widgets, that only need the access to the viewmodel registered in the parent, we have ViewModelProviderMixin for Widget
Additional information
This library is maintained by Developers at Donut.