2024
Flutter Timer BLoC
A Flutter learning project that models a countdown timer with explicit BLoC events, states, and stream-driven updates.
- Role
- Flutter Developer
- Categories
- Mobile, Lab / Learn
Problem
A countdown timer has a small interface but several possible states: ready, running, paused, and complete. This project explores how an event-driven BLoC can keep those state transitions explicit and separate from Flutter widgets.
Approach
The application defines a TimerBloc that responds to start, pause, resume, reset, and internal tick events. A Ticker emits a value every second, while the BLoC owns the stream subscription and cancels it when the timer is reset or disposed.
The presentation layer provides the BLoC through BlocProvider, selects the remaining duration for the timer display, and renders only the actions appropriate to the current state. The Material interface supports a 60-second timer with play, pause, resume, and replay controls.
Outcome
The result is a compact Flutter reference project that demonstrates a complete event-to-state flow, stream-subscription lifecycle management, and state-dependent controls using flutter_bloc. It is intended as a learning implementation; the repository does not claim user-facing product metrics.
Responsibilities
- Built the Flutter application shell and Material timer interface.
- Modelled the timer lifecycle with dedicated BLoC events and states.
- Connected a periodic stream to the BLoC and managed its subscription lifecycle.
- Used
BlocProvider,BlocBuilder, andcontext.selectto keep presentation reactive to state changes. - Used Equatable-based state values to support predictable state comparisons.
