2024
Flutter Counter Cubit
A focused Flutter learning project that demonstrates predictable counter state management with Cubit and flutter_bloc.
- Role
- Flutter Developer
- Categories
- Mobile, Lab / Learn
Problem
Even a small interactive screen benefits from separating state changes from its UI. This project explores a simple, testable pattern for updating and rendering state in a Flutter application without putting counter logic directly in a widget.
Approach
The application uses a CounterCubit as the single source of truth for an integer counter. It exposes explicit increment and decrement actions, while a BlocBuilder rebuilds the view whenever the Cubit’s state changes.
The Flutter UI is organised into a page that provides the Cubit and a view that presents the current value with Material floating-action buttons. A custom BlocObserver records state changes during development, making the state-transition flow easier to inspect.
Outcome
The result is a small, multi-platform Flutter counter application that demonstrates Cubit’s core loop: user action, state emission, and reactive UI update. It serves as a clear reference implementation for structuring simple feature state with flutter_bloc; the repository does not claim user-facing product metrics.
Responsibilities
- Built the Flutter application structure and Material user interface.
- Implemented a Cubit with explicit increment and decrement state transitions.
- Connected the presentation layer to state with
BlocProviderandBlocBuilder. - Added a
BlocObserverto log state changes during development.
