Package selection guidance compiled from public package information, community data, and project usage.
Momentum is a Flutter package that implements the Model-View-Controller (MVC) pattern, serving as a unified solution for state management, dependency injection, and service location. It streamlines app architecture by separating concerns through dedicated model, view, and controller layers, enabling scalable and maintainable code. Momentum integrates seamlessly with Flutter's widget tree and supports all major platforms, including Android, iOS, Web, macOS, Windows, and Linux. Its lightweight design promotes clean code organization and efficient data flow across components.
Use cases
Building scalable Flutter applications
Managing complex app states
Implementing dependency injection
Replacing multiple state management solutions
Creating modular and testable code
Key features
Built-in MVC architecture
Integrated dependency injection
Service locator functionality
Cross-platform support
Minimal boilerplate
Automatic controller lifecycle management
Suitable for
Developers seeking structured app architecture
Teams wanting to unify state and dependency management
Projects requiring maintainable and modular code
Flutter apps targeting multiple platforms
Developers preferring MVC over other patterns
Considerations
Learning curve for developers unfamiliar with MVC
Limited community adoption compared to alternatives
May require refactoring existing codebases
Best suited for medium to large-scale projects
Not ideal for simple or prototype apps
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
MVC pattern for flutter. Works as state management, dependency injection and service locator.
Model View Controller
Here's a diagram describing the flow between the state (model), widget (view) and the logic (controller):
Both MomentumController and MomentumModel are abstract classes that needs to be implemented. A pair of model and controller is called a component. MomentumBuilder is simply a widget. This is used to listen to controllers for rebuilds and accessing models to display their values.
Example
If you want to see a full code example that runs. Visit the example tab for more details or you can visit the official webpage. Otherwise, if you only want to see a glimpse of how momentum works, read the Overview and FAQs below.
Advance Example:Listify (clone the repo and run the app, requires Flutter 2.0.0)
Overview
MomentumModel - the data or state. Must be Immutable.
MomentumBuilder - the view or widget to display the state.
MomentumBuilder(
controllers: [ProfileController], /// injects both `ProfileController` and `ProfileModel`.
builder: (context, snapshot) {
var profileState = snapshot<ProfileModel>(); /// grab the `ProfileModel` using snapshot.var username = profileState.username;
return// some widgets here ...
}
)
MomentumController - the logic to manipulate the model or state.