Flutter bloc workshop. This project contains 3 different sample projects that are used to demonstrate the use of bloc in flutter.
-
Counter App (Using cubit)
-
Timer App (Using bloc and bloc_test)
-
Product App (Complete application with MVVM architecture using bloc)
- Flutter SDK version 3.13.6 or above
All the sample projects are in different branches. To get started, clone the repo and checkout the branch you want to work on.
git clone
git checkout <branch-name>
All the projects have a common structure. The project structure is as follows:
lib lib/app - Contains the application-specific code lib/data - Contains the data layer code (Repository, API, Database) lib/feature - Contains the feature-specific code lib/utils - Contains the utility code
Initial Setup step-1: flutter setup with dependencies
Counter App
step-2.0: initial setup for cubit
step-2.1- completed setup for cubit
Timer App
step-3.0: initial setup for bloc
step-3.1- completed setup for bloc
step-3.2: example app with test cases without Expect
step-3.3: example app with completed test cases
Product App
step-4.0: folder structure and files for app
step-4.1: code for bloc and UI without connections
step-4.2: complete code
Branch: step-2.1
This is a simple counter app that uses a cubit to manage the state.
Branch: step-3.3
This is a simple timer app that uses Bloc to manage the state. It also uses bloc_test to test the bloc. Also, a custom bloc observer to log the state changes.
Branch: step-4.2
This app has MVVM architecture using bloc. This app has two screens - Categories and Product List. The app uses the bloc to manage the state. It also uses go_route to navigate between the screens.