A clean architecture Flutter application built using Bloc, Dio, and shared_preferences.
This project was initially an assessment, but I enjoyed it so much that I learned a lot in the process. If I had more time, I would have worked more on the UI design.
This project is built using Clean Architecture together with Test Driven Development (TDD). I chose this architecture because it makes code easier to write, maintain, and scale. Below is a detailed explanation of the components and flow of the architecture:
- Clean Architecture: The app is structured following Clean Architecture principles.
- Test Driven Development (TDD): Tests are written before the concrete implementations of classes, ensuring a high level of code reliability.
- Dependency Inversion: The project follows dependency inversion principles, making the codebase flexible and easier to manage.
- Dependency Injection: The project uses dependency injection to manage dependencies efficiently.
- Login: Users can log in.
- Logout: Users can log out.
- Add new todo: Users can add a new todo.
- Edit an existing todo: Users can edit an existing todo.
- Delete an existing todo: Users can delete an existing todo with a swipe-to-delete gesture.
- Pagination: Supports endless pagination.
- Offline Cache: Supports offline caching.
- Bloc: For state management.
- Dio: For handling HTTP requests.
- shared_preferences: For local storage solutions.
- Mockito: For creating mock versions of classes during testing.
- get_it: For dependency injection.
The project is divided into several features, with each feature containing the following directories:
- Data: Contains data sources, models, and repositories.
- Domain: Contains entities, repositories, and use cases.
- Presentation: Contains UI components like screens, widgets, and Bloc implementations.
- Upwards Flow: Data flows upwards towards the UI.
- Downwards Flow: Events flow downwards from the UI to the data layer.
Below is a visual representation of the architecture (image credits: Reso Coder).
- Mockito: Used for creating mock versions of classes.
- Test Driven Development (TDD): Tests are written before the implementation of classes, following the TDD approach.
Below are snapshots of the application features.
This project demonstrates the use of Clean Architecture in Flutter applications, ensuring a scalable, maintainable, and testable codebase.
To run this project, clone the repo, run flutter pub get
, then run flutter run
.
To log in, you can use the following credentials:
{
"username": "emilys",
"password": "emilyspass",
}