Number Trivia App using clean architecture and test-driven development
Project inspired by Reso Coder's Clean Architecture TDD Course.
- ⭐ State Management using the BLoC pattern
- ⭐ Test-Driven Development with unit tests for domain and data layers using
mocktail
- ⭐ Dependency Injection using
get_it
- ⭐ Functional Programming with
dartz
package - ⭐ Equality Checks in classes using
equatable
- ⭐ REST API integration with
http
- ⭐ Exception Handling using custom Failure classes
- ⭐ Persistent Data using shared preferences
- ⭐ Null Safety support for safer, more reliable code
This project follows the principles of Clean Architecture. The code is split into the following layers:
- Domain Layer: Contains core business logic and use cases.
- Data Layer: Handles data from APIs, local databases, or any external sources.
- Presentation Layer: Manages the user interface (UI) using BLoC for state management.
By using this structure, it's easier to test, modify, and extend the application, especially in large-scale projects.
Bloc (Business Logic Component) is used for managing states across the app. This makes the app's business logic independent of the UI.
The get_it
package is used for easy dependency injection, making it simple to switch implementations or mock objects for testing.
The dartz
package enables functional programming patterns, such as using Either
for handling failures and successes, ensuring clean and maintainable code.
The app uses the http
package for fetching data from a REST API. It retrieves [describe the data, e.g., trivia, user information].
Custom Failure
classes handle exceptions gracefully, ensuring a smooth user experience when errors occur.
This project is built with Dart's Null Safety features enabled, ensuring fewer runtime errors and safer code by handling null values properly.
This project follows Test-Driven Development (TDD) practices. Unit tests are provided for the domain, data, and presentation layers. To run the tests, use:
flutter test
We use the mocktail
package for mocking dependencies in the tests. This ensures clean and isolated testing of components by mocking external dependencies such as services and repositories.
Feel free to contribute to this project. You can do so by:
- Forking the repository.
- Creating a feature branch (
git checkout -b feature/your-feature
). - Committing your changes (
git commit -m 'Add some feature'
). - Pushing to the branch (
git push origin feature/your-feature
). - Opening a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
More tutorials and information on Flutter development can be found on Reso Coder.
This updated README includes information about:
- The use of
mocktail
for testing. - Support for Null Safety, highlighting that the project uses Dart’s safety features to avoid null reference errors.
If you'd like to add more details, like specific features or screenshots, feel free to reach out!