This project is an application that utilizes the BLoC architecture pattern with a single state, Dio for network management, and Drift for local database storage. It demonstrates a robust way to handle data synchronization between a remote API and a local cache using a unified state approach.
Important
Similar project with multiple states:
👉 SampleDriftDatabaseWithBlocPattern 👈
- Bloc Patterns (Single State): Along with repositories and services, it separates business logic, data access, and UI using streams to manage data flow via a single state class. (Documentation)
- Dio Network Manager: Responsible for making asynchronous HTTP requests and retrieving data from remote servers.
- Drift Database: Handles local persistence, allowing for complex queries and full offline functionality. (Documentation)
- Cached Network Image: Efficiently loads and caches remote images for offline availability.
- Flutter SDK: 3.41.4
- Dart Version: 3.11.1
The project parses data from the SpaceX API:
- GitHub: r-spacex/SpaceX-API
- Postman Docs: SpaceX API Documentation
- Bloc Library: Getting Started Guide
- Tutorials: Flutter Timer Tutorial
- Comparison: BlocBuilder vs BlocConsumer vs BlocListener
- Architecture: Why use a Repository layer?
- Error Handling: Stopping Dio on Connection Loss
- Error Handling: Suppression of Request Errors
- Error Handling: Dio Official Handling Guide
If you find this project useful, please give it a star!
Check out the stargazers here
Feedback, bug reports, and feature requests are welcome! Feel free to open an issue or submit a pull request.