jetpack
1.0.8, released a year ago by praja.buzz
Android Jetpack inspired abstractions and utilities for state management in Flutter.
What it does
Provides a state management architecture using ViewModel, LiveData, and EventQueue patterns ported from Android Jetpack. It allows developers to write imperative state update code and manage UI side effects cleanly.
AI-written summary of version 1.0.8, based on the package's README and metadata. Report an inaccuracy
Use it when
- You prefer Android Jetpack's ViewModel and LiveData patterns for state management
- You want to write imperative state-updating code instead of pure streams
- You need a lightweight way to manage related state streams without heavy boilerplate
Skip it when
- You are fully invested in reactive programming with Dart Streams or other state management libraries like BLoC or Riverpod
- You want a zero-setup solution without building a custom ViewModelFactory
Strengths
- Familiar patterns for developers coming from Android Jetpack
- Low coupling and flexible architecture
- Supports exposing multiple state variables without selectors
Weaknesses
- Requires boilerplate setup such as custom ViewModelFactory implementation
- Niche package compared to major state management solutions like Provider, BLoC, or Riverpod
Setup
- Kind
- Flutter widgets
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 1
Requires creating a ViewModelFactory, providing it at the root of the app using ViewModelScopeProvider, and wrapping page contents with ViewModelScope.
class CounterViewModel extends ViewModel {
final MutableLiveData<int> _counter = MutableLiveData(0);
LiveData<int> get counter => _counter;
void increment() => _counter.value++;
}Alternatives
Packages that do the same job and could replace jetpack.
- yx_state
A state management library for Dart and Flutter applications.
82Compare - cached_query
Library for caching, background fetching, and managing server state in Dart and Flutter.
90Compare - bloc
A Dart library for implementing the BLoC pattern with Cubits and Blocs.
92Compare - flutter_mobx
Flutter integration for MobX, providing reactive Observer widgets.
92Compare
Works with
Packages commonly used together with jetpack: ones it builds on, ones built on it, and its own family.